Skip to content

TG100 sample ROMS

Technical discussion which is not directly related to VGM files. Talk about Hardware and Software.

Moderator: Staff

Post by vampirefrog »

Here's a simplification of that there test mode beep thing. I am sure it's very easy to convert to VGM commands, but I am not familiar with how that happens. I could do it on-chip when transmitting.

Code: Select all

    wait A0-A3 D0-D7
   32031  02  00
       0  02  02
       1  02  01
       7  02  03
       0  02  05
       1  02  04
    9024  01  00
       0  00  48
    4519  01  01
       1  00  00
       0  00  08
       1  00  00
       7  00  10
       0  00  01
       0  00  88
    9024  02  04
    4519  02  00
       1  02  02
       0  02  01
       7  02  03
       1  02  05
       0  02  04
    9023  01  02
       1  00  48
    4519  01  03
       0  00  00
       1  00  08
       0  00  00
       7  00  10
       1  00  01
       0  00  88
    9023  02  04
    4520  02  00
       1  02  02
       0  02  01
       7  02  03
       1  02  05
       0  02  04
    9024  01  04
       0  00  48
    4519  01  05
       1  00  00
       0  00  08
       1  00  00
       7  00  10
       0  00  01
       1  00  88
    9023  02  04
    4520  02  00
       0  02  02
       1  02  01
       7  02  03
       0  02  05
       1  02  04
    9023  01  06
       0  00  48
    4520  01  08
       0  00  00
       0  00  08
       1  00  00
       7  00  10
       0  00  01
       1  00  88
    9023  02  04
    4520  02  00
       0  02  02
       1  02  01
       7  02  03
       0  02  05
       0  02  04
    9024  01  09
       0  00  48
    4519  01  0a
       1  00  00
       0  00  08
       1  00  00
       7  00  10
       0  00  01
       0  00  88
    9024  02  04
    4519  02  00
       1  02  02
       0  02  01
       7  02  03
       1  02  05
       0  02  04
    9023  01  0b
       1  00  48
    4519  01  0c
       0  00  00
       1  00  08
       0  00  00
       7  00  10
       1  00  01
       0  00  88
    9023  02  04
    4520  02  00
       0  02  02
       1  02  01
       7  02  03
       0  02  05
       1  02  04
    9023  01  0d
       0  00  48
    4520  01  0e
       0  00  00
       0  00  08
       1  00  00
       7  00  10
       1  00  01
       0  00  88
    9024  02  04
    4519  02  00
       1  02  02
       0  02  01
       7  02  03
       1  02  05
       0  02  04
    9023  01  10
       1  00  48
    4519  01  11
       0  00  00
       1  00  08
       0  00  00
       7  00  10
       0  00  01
       1  00  88
    9023  02  04
    4520  02  00
       1  02  02
       0  02  01
       7  02  03
       1  02  05
       0  02  04
    9023  01  12
       1  00  48
    4519  01  13
       1  00  00
       0  00  08
       0  00  00
       7  00  10
       1  00  01
       0  00  88
    9023  02  04
    4520  02  00
       0  02  02
       1  02  01
       7  02  03
       0  02  05
       1  02  04
    9023  01  14
       0  00  48
    4520  01  15
       0  00  00
       1  00  08
       0  00  00
       7  00  10
       0  00  01
       1  00  88
    9023  02  04
    4520  02  00
       0  02  02
       1  02  01
       7  02  03
       0  02  05
       1  02  04
    9023  01  16
       0  00  48
    4520  01  18
       0  00  00
       0  00  08
       1  00  00
       7  00  10
       0  00  01
       1  00  88
    9023  02  04
    4520  02  00
       1  02  02
       0  02  01
       7  02  03
       0  02  05
       1  02  04
    9023  01  19
       0  00  48
    4520  01  1a
       0  00  00
       1  00  08
       0  00  00
       7  00  10
       0  00  01
       1  00  88
    9023  02  04
    4520  02  00
       1  02  02
       0  02  01
       7  02  03
       1  02  05
       0  02  04
    9023  01  1b
       1  00  48
    4519  01  1c
       0  00  00
       1  00  08
       0  00  00
       7  00  10
       1  00  01
       0  00  88
    9023  02  04
    4520  02  00
       0  02  02
       1  02  01
       7  02  03
       0  02  05
       1  02  04
    9023  01  1d
       0  00  48
    4520  01  1e
       0  00  00
       1  00  08
       0  00  00
       7  00  10
       1  00  01
       1  00  88
    9023  02  04
    4520  01  00
       0  00  00
       0  00  08
       1  00  00
       7  00  10
       0  00  01
       1  00  88
    9023  02  04
    4520  02  00
       0  02  02
       1  02  01
       7  02  03
       1  02  05
       0  02  04
    9024  01  01
       0  00  48
    4519  01  02
       1  00  00
       0  00  08
       1  00  00
       7  00  10
       0  00  01
       1  00  88
    9023  02  04
    4520  02  00
       0  02  02
       1  02  01
       7  02  03
       0  02  05
       1  02  04
    9023  01  03
       0  00  48
    4519  01  04
       1  00  00
       0  00  08
       1  00  00
       7  00  10
       0  00  01
       0  00  88
    9024  02  04
    4519  02  00
       1  02  02
       0  02  01
       7  02  03
       1  02  05
       1  02  04
    9023  01  05
       0  00  48
    4520  01  06
       0  00  00
       0  00  08
       1  00  00
       7  00  10
       0  00  01
       1  00  88
    9023  02  04
    4520  02  00
       1  02  02
       0  02  01
       7  02  03
       0  02  05
       1  02  04
    9023  01  08
       0  00  48
    4520  01  09
       0  00  00
       1  00  08
       1  00  00
       7  00  10
       0  00  01
       0  00  88
    9024  02  04
    4520  02  00
       0  02  02
       1  02  01
       7  02  03
       0  02  05
       1  02  04
    9023  01  0a
       0  00  48
    4520  01  0b
       0  00  00
       0  00  08
       1  00  00
       7  00  10
       0  00  01
       1  00  88
    9023  02  04
    4520  02  00
       0  02  02
       1  02  01
       7  02  03
       0  02  05
       0  02  04
    9024  01  0c
       0  00  48
    4519  01  0d
       1  00  00
       0  00  08
       1  00  00
       7  00  10
       0  00  01
       0  00  88
    9024  02  04
    4520  02  00
       0  02  02
       0  02  01
       7  02  03
       1  02  05
       0  02  04
    9023  01  0e
       1  00  48
    4519  01  10
       0  00  00
       1  00  08
       0  00  00
       7  00  10
       1  00  01
       0  00  88
    9023  02  04
    4520  02  00
       0  02  02
       1  02  01
       7  02  03
       1  02  05
       0  02  04
    9024  01  11
       0  00  48
    4519  01  12
       1  00  00
       0  00  08
       0  00  00
       8  00  10
       0  00  01
       0  00  88
    9024  02  04
    4519  02  00
       1  02  02
       0  02  01
       7  02  03
       1  02  05
       0  02  04
    9023  01  13
       1  00  48
    4519  01  14
       0  00  00
       1  00  08
       0  00  00
       7  00  10
       1  00  01
       0  00  88
    9023  02  04
    4520  02  00
       1  02  02
       0  02  01
       7  02  03
       0  02  05
       1  02  04
    9023  01  15
       0  00  48
    4520  01  16
       0  00  00
       0  00  08
       1  00  00
       7  00  10
       0  00  01
       1  00  88
    9023  02  04
    4520  02  00
       0  02  02
       1  02  01
       7  02  03
       0  02  05
       1  02  04
    9023  01  18
       0  00  48
    4520  01  19
       0  00  00
       1  00  08
       0  00  00
       7  00  10
       1  00  01
       0  00  88
    9023  02  04
    4520  02  00
       0  02  02
       0  02  01
       7  02  03
       0  02  05
       1  02  04
    9023  01  1a
       0  00  48
    4520  01  1b
       0  00  00
       0  00  08
       1  00  00
       7  00  10
       0  00  01
       1  00  88
    9023  02  04
    4520  02  00
       0  02  02
       1  02  01
       7  02  03
       0  02  05
       1  02  04
    9023  01  1c
       0  00  48
    4520  01  1d
       0  00  00
       1  00  08
       0  00  00
       7  00  10
       1  00  01
       0  00  88
    9023  02  04
    4520  02  00
       0  02  02
       1  02  01
       7  02  03
       0  02  05
       1  02  04
    9023  01  1e
       0  00  48
    4520  02  00
       1  02  02
       0  02  01
       7  02  03
       1  02  05
       0  02  04
    9023  01  00
       1  00  48
    4519  01  01
       0  00  00
       1  00  08
       0  00  00
       7  00  10
       1  00  01
       1  00  88
    9023  02  04
    4520  02  00
       0  02  02
       1  02  01
       7  02  03
       0  02  05
       0  02  04
    9024  01  02
       0  00  48
    4519  01  03
       1  00  00
       0  00  08
       0  00  00
       7  00  10
       1  00  01
       0  00  88
    9024  02  04
    4519  02  00
       1  02  02
       1  02  01
       7  02  03
       0  02  05
       1  02  04
    9023  01  04
       0  00  48
    4520  01  05
       0  00  00
       0  00  08
       1  00  00
       7  00  10
       0  00  01
       0  00  88
    9024  02  04
    4519  02  00
       1  02  02
       0  02  01
       7  02  03
       1  02  05
       0  02  04
    9023  01  06
       1  00  48
    4519  01  08
       1  00  00
       0  00  08
       0  00  00
       7  00  10
       1  00  01
       0  00  88
    9023  02  04
    4520  02  00
       1  02  02
       0  02  01
       7  02  03
       0  02  05
       1  02  04
    9023  01  09
       0  00  48
    4520  01  0a
       0  00  00
       1  00  08
       0  00  00
       7  00  10
       0  00  01
       1  00  88
    9023  02  04
    4520  02  00
       0  02  02
       1  02  01
       7  02  03
       0  02  05
       1  02  04
    9023  01  0b
       0  00  48
    4520  01  0c
       0  00  00
       0  00  08
       1  00  00
       7  00  10
       0  00  01
       1  00  88
    9023  02  04
    4520  02  00
       1  02  02
       0  02  01
       7  02  03
       0  02  05
       1  02  04
    9023  01  0d
       0  00  48
    4520  01  0e
       0  00  00
       1  00  08
       0  00  00
       7  00  10
       0  00  01
       1  00  88
       1  00  88
  • ctr Offline
  • Posts: 492
  • Joined: 2013-07-17, 23:32:39

Post by ctr »

While it looks better now, I'm not sure if you're still getting accurate data. The order of the writes should be something like 01,02,00,(02,00 ...),01,02,00,(02,00...) for the addresses.

I reversed the "play test tone" function and it writes to the chip in this order:

Code: Select all

01 = 00  - channel number
02 = 00  - pan
00 = 00
02 = 02  - pitch lo / sample# hi
00 = 08
02 = 01  - sample# lo
00 = 00
02 = 03  - pitch hi
00 = 10
02 = 05  - volume
00 = 01
02 = 04  - key on
00 = 88
Looking at your log, i think the problem is that you're skipping commands. I see many of the 0x00 writes got through while few 0x02 did. Check the amount of data written after each 0x01 (set channel) write.

Post by vampirefrog »

Alright, it's probably skipping commands because the DMA ISR isn't over yet when a new command arrives. But how would I translate these to VGM commands? it looks like I'd have to send less bytes this way.
  • ctr Offline
  • Posts: 492
  • Joined: 2013-07-17, 23:32:39

Post by ctr »

MultiPCM vgm command is "0xb5 aa dd" where aa = port(A0-3) and dd = data(D0-D7). Keep in mind that VGMPlay will not be able to play any logs right now anyway, due to the use of 12-bit samples which the current MultiPCM emulator does not support. For a short delay use "0x70+(samples-1)".

Post by vampirefrog »

Is this good?

It looks like there are a few more commands compared to what you listed, and that is 01 13, 02 04, 00 48, which is probably key off.

Code: Select all

01 12
02 04
00 48
01 13
02 00
00 00
02 02
00 08
02 01
00 00
02 03
00 10
02 05
00 01
02 04
00 88
01 13
02 04
00 48
01 14
02 00
00 00
02 02
00 08
02 01
00 00
02 03
00 10
02 05
00 01
02 04
00 88
01 14
02 04
00 48
01 15
02 00
00 00
02 02
00 08
02 01
00 00
02 03
00 10
02 05
00 01
02 04
00 88
01 15
02 04
  • ctr Offline
  • Posts: 492
  • Joined: 2013-07-17, 23:32:39

Post by ctr »

yeah this looks better. And yes that sequence (01 13, 02 04, 00 48) is key off.

Post by vampirefrog »

Okay, here are more captures, this time as VGM commands.

I am not sure why, but some waits are very large so I've limited them to 0xffff. In reality they're probably very small, but there's some issue with the way I'm capturing the timer value, it's behaving quite strangely. I've had to do a strange workaround where the timer that is triggering the DMA for the data (which is not really a timer, it uses the timer peripheral of the mcu, but it doesn't really count time, and it's the only way to trigger the DMA from an external pin) is also triggering another timer which is triggering another DMA stream which reads the value of yet another timer. Did I mention that the reference manual for the STM32F4 I'm using has over 1700 pages?

I hope I got the endianness right.

Let's have a look at the test mode 10 data:

Code: Select all

      70 00 00
      71 02 03
      70 00 10
      71 02 05
      70 00 01
       1 02 04
       3 00 88
    7979 01 10
      70 02 04
      71 00 48
    4724 01 11
      70 02 00
      71 00 00
      70 02 02
      70 00 08
      71 02 01
      70 00 00
      71 02 03
      70 00 10
      71 02 05
      70 00 01
       1 02 04
       3 00 88
    7979 01 11
      70 02 04
      71 00 48
    4724 01 12
      70 02 00
      71 00 00
      70 02 02
      71 00 08
      70 02 01
      71 00 00
      70 02 03
      71 00 10
      70 02 05
      71 00 01
       1 02 04
       2 00 88
    7979 01 12
      71 02 04
      70 00 48
    4724 01 13
      71 02 00
      70 00 00
      71 02 02
      70 00 08
      70 02 01
      71 00 00
      70 02 03
      71 00 10
      70 02 05
      71 00 01
       1 02 04
       3 00 88
    7978 01 13
      71 02 04
      70 00 48
    4724 01 14
      71 02 00
      70 00 00
      71 02 02
      70 00 08
      71 02 01
      70 00 00
      71 02 03
      70 00 10
      71 02 05
      70 00 01
       1 02 04
       3 00 88
    7979 01 14
      70 02 04
      71 00 48
    4724 01 15
      70 02 00
      71 00 00
      70 02 02
      71 00 08
      70 02 01
      70 00 00
      71 02 03
      70 00 10
      71 02 05
      70 00 01
       1 02 04
       3 00 88
    7979 01 15
      70 02 04
      71 00 48
    4724 01 16
      70 02 00
      71 00 00
      70 02 02
      71 00 08
      70 02 01
      71 00 00
      70 02 03
      71 00 10
      70 02 05
      71 00 01
       1 02 04
       2 00 88
    7979 01 16
      71 02 04
      70 00 48
    4724 01 18
      71 02 00
      70 00 00
      71 02 02
      70 00 08
      71 02 01
      70 00 00
      71 02 03
      70 00 10
      70 02 05
      71 00 01
       1 02 04
       3 00 88
    7978 01 18
      71 02 04
      70 00 48
    4724 01 19
      71 02 00
      70 00 00
      71 02 02
      70 00 08
      71 02 01
      70 00 00
      71 02 03
      70 00 10
      71 02 05
      70 00 01
       1 02 04
       3 00 88
    7979 01 19
      70 02 04
      71 00 48
    4724 01 1a
      70 02 00
      71 00 00
      70 02 02
      71 00 08
      70 02 01
      71 00 00
      70 02 03
      71 00 10
      70 02 05
      70 00 01
       2 02 04
       2 00 88
    7979 01 1a
      70 02 04
      71 00 48
    4724 01 1b
      70 02 00
      71 00 00
      70 02 02
      71 00 08
      70 02 01
      71 00 00
      70 02 03
      71 00 10
      70 02 05
      71 00 01
       1 02 04
       2 00 88
    7979 01 1b
      71 02 04
      70 00 48
    4724 01 1c
      71 02 00
      70 00 00
      71 02 02
      70 00 08
      71 02 01
      70 00 00
      71 02 03
      70 00 10
      71 02 05
      70 00 01
       1 02 04
       3 00 88
    7978 01 1c
      71 02 04
      70 00 48
    4724 01 1d
      71 02 00
      70 00 00
      71 02 02
      70 00 08
      71 02 01
      70 00 00
      71 02 03
      70 00 10
      71 02 05
      70 00 01
       1 02 04
       3 00 88
    7979 01 1d
      70 02 04
      71 00 48
    4724 01 1e
      70 02 00
      71 00 00
      70 02 02
      71 00 08
      70 02 01
      71 00 00
      70 02 03
      71 00 10
      70 02 05
      71 00 01
       1 02 04
       2 00 88
    7979 01 1e
      70 02 04
      70 00 48
    4795 01 00
      70 02 00
      71 00 00
      70 02 02
      71 00 08
      70 02 01
      71 00 00
      70 02 03
      71 00 10
      70 02 05
       1 00 01
       1 02 04
       2 00 88
    7979 01 00
      70 02 04
      71 00 48
    4724 01 01
      70 02 00
      71 00 00
      70 02 02
      71 00 08
      70 02 01
      71 00 00
      70 02 03
      71 00 10
      70 02 05
      71 00 01
       1 02 04
       2 00 88
    7979 01 01
      71 02 04
      70 00 48
    4724 01 02
      71 02 00
      70 00 00
      70 02 02
      71 00 08
      70 02 01
      71 00 00
      70 02 03
      71 00 10
      70 02 05
      71 00 01
       1 02 04
       3 00 88
       3 00 88
Attachments
demosong.cap.gz
(2.22 MiB) Downloaded 309 times
startup.cap.gz
(49.12 KiB) Downloaded 297 times
testmode.cap.gz
(250 Bytes) Downloaded 310 times
  • User avatar
  • ValleyBell Offline
  • Posts: 4768
  • Joined: 2011-12-01, 20:20:07
  • Location: Germany

Post by ValleyBell »

I tried to convert your demosong capture into a listenable VGM and this is what I've got.
The archive includes a .vgm, a tool to convert the 12-bit samples in the ROM to 8-bit and a tool to adjust the timing of the wait commands.
I had to divide the tick times by 250M in order to get a okay-ish speed.

You can recognise the song at 0:40, but there are lots of bad (and hanging) notes. But for a proof-of-concept VGM log it's quite an achievement.
Some of the audible bugs might also be caused by improper emulation. (e.g. The current MultiPCM core doesn't emulate 512 instruments, but only 256.)

Post by vampirefrog »

As I've said, some of the waits are 0xffff. I think setting those to 0 or 1 might give better results. I can try a simpler MIDI file, perhaps playing a few notes on the keyboard, and see how that converts. Also, can you convert to 16 instead of 8? Just duplicate the 4 last bits, so 0x123 turns into 0x1233.

I'm still trying to figure out how to get the timing info properly from the microcontroller, at this point. What happens is that it counts up but sometimes there's a timer sample that is from a previous buffer and it yields a negative result, so that turns into a negative 32 bit number. There's some weird timing issue. It increases if I make the buffer smaller.
  • ctr Offline
  • Posts: 492
  • Joined: 2013-07-17, 23:32:39

Post by ctr »

it's converted to 8-bit because Sega only used 8-bit samples. If we're to keep the 12-bit samples or convert to 16-bit the emulation has to be rewritten or commands converted to OPL4 (which might be an issue due to lower polyphony)

Post by vampirefrog »

So the MultiPCM code only emulates 8 bit mode, whereas the real chip supports 8, 12 and 16 bit?
  • ctr Offline
  • Posts: 492
  • Joined: 2013-07-17, 23:32:39

Post by ctr »

Yes, our emulation only does 8 bit samples. the YMW258-F supports 8-bit and 12-bit samples. Nobody knows if it supports 16-bit samples.
  • User avatar
  • ValleyBell Offline
  • Posts: 4768
  • Joined: 2011-12-01, 20:20:07
  • Location: Germany

Post by ValleyBell »

I noticed that I had a stupid bug in my VGM speed adjustment tool that screwed up all timing and I fixed it.
The VGM's timing seems good now - and I didn't even ignore the 65535 sample delays. And considering that I divide the timing by 256 now, those delays don't seem like calculation errors.
WIth your recording rate, a 1/60 Hz delay would have about 188000 samples.

And finally, after fixing some mistakes in MAME's MultiPCM core, the VGM dump is finally working and it actually sounds good!

EDIT: We are still a bit unsure about the MultiPCM's clock divider and sample rate. I tried to get the pitch right compared to some videos and ended up with a clock divider of 224. (using the a clock of 9.4 MHz) That results in a sample rate of 41964 Hz.
The VGM uses a different clock btw, because MAME's emulation works with a divider of 180.

Post by vampirefrog »

That sounds a lot better, ValleyBell. It's basically the original with the right notes but jittery timing. I trust that you found the recording somewhere and compared it. If not, I can make a recording.

I'm currently experimenting with STM32 timers to try to set it up to capture timing correctly. It's strange that you still have to divide the timing, I thought I had configured the internal timer to 44100, but I guess I was wrong.
  • User avatar
  • ValleyBell Offline
  • Posts: 4768
  • Joined: 2011-12-01, 20:20:07
  • Location: Germany

Post by ValleyBell »

I just noticed something: Your capture seems to write the delay values in Big Endian instead of Little Endian. That would explain the /256 divider.
We need to do something with those 0xFFFF delays though. Leaving them as 0xFFFF makes the log hours long, but replacing them with a 0-sample-delay makes it way too fast.
Post Reply