MAMEWorld >> EmuChat
View all threads Index   Threaded Mode Threaded  

Pages: 1

TheShanMan
MAME Fan
Reged: 08/14/08
Posts: 8
Send PM


MAME debugger question
#332569 - 09/30/14 04:43 PM


I'm trying to understand something about how the sounds work in The Simpsons so I've loaded it in the 154 MAME debugger and am trying to set a watchpoint on the block of addresses that contain the sounds so I can get the debugger to break when a sound starts being played. Here's where simpsons.c says the sounds are mapped in memory:

Code:

	ROM_REGION( 0x140000, "k053260", 0 ) /* samples for the 053260 */
ROM_LOAD( "072-d05.1f", 0x000000, 0x100000, CRC(1397a73b) SHA1(369422c84cca5472967af54b8351e29fcd69f621) )
ROM_LOAD( "072-d04.1d", 0x100000, 0x040000, CRC(78778013) SHA1(edbd6d83b0d1a20df39bb160b92395586fa3c32d) )



So I tried setting the watchpoint like this:


Code:

wpdset 0x140000,0x100000,r


And I get "no matching memory space found for CPU (whatever)" whether the current CPU is ":maincpu" or ":audiocpu". I've also tried the command without the "0x" with the same result.

What am I doing wrong?



AWJ
Reged: 03/08/05
Posts: 936
Loc: Ottawa, Ontario
Send PM


Re: MAME debugger question new [Re: TheShanMan]
#332579 - 09/30/14 09:32 PM


You're... unfortunately doing it so completely wrong I'm not sure where to start explaining.

Don't look at the ROM definitions to see "where things are mapped in memory", look at the address maps. In the case of simpsons, you can see that the YM2151 and the K053260 are both mapped on z80_map, the former at F800-F801 and the latter at FC00-FC2F. Go down to the MACHINE_CONFIG and you can see that z80_map is the program address map used by "audiocpu". So to break when the game accesses the sound chips, you'd set watchpoints on those address ranges for "audiocpu", using wpset (not wpdset)

wpdset is for Harvard-architecture processors that have separate program and data address spaces (mainly DSPs). If the address map you wanted to set a watchpoint in was a MCFG_CPU_DATA_MAP you'd use wpdset. If it was an IO address space (MCFG_CPU_IO_MAP) you'd use wpiset.



TheShanMan
MAME Fan
Reged: 08/14/08
Posts: 8
Send PM


Re: MAME debugger question new [Re: AWJ]
#332586 - 10/01/14 12:00 AM


Lol. No doubt I'm way off, which is why I gave up in frustration and came here.

I don't think what you're suggesting is what I'm after though, and in fact the debugger never breaks with those watchpoints, at least not when in the test menu's sound check screen.

What I was hoping to have happen is break in the debugger when it starts accessing certain sounds in order to see how those sounds are handled. Particularly, where a sound clip starts and where it ends, with the ultimate goal of replacing some sound clips altogether. That's why I was looking at the 140000 and beyond memory range. Any suggestions on how I might accomplish this?

Thanks for the help.



AWJ
Reged: 03/08/05
Posts: 936
Loc: Ottawa, Ontario
Send PM


Re: MAME debugger question new [Re: TheShanMan]
#332590 - 10/01/14 03:15 AM


You'll have to look at src/emu/sound/k053260.c to see how the sound chip is programmed and what the sample data format is (looks like it has two formats, 8-bit linear PCM and a 4-bit custom ADPCM)



TheShanMan
MAME Fan
Reged: 08/14/08
Posts: 8
Send PM


Re: MAME debugger question new [Re: AWJ]
#332601 - 10/01/14 07:37 AM


Thank you for your help! I'll start looking at that!



TheShanMan
MAME Fan
Reged: 08/14/08
Posts: 8
Send PM


Re: MAME debugger question new [Re: AWJ]
#332747 - 10/04/14 06:42 AM


It is indeed 8 bit linear PCM. I was able to pull the raw PCM into Audacity and it plays. However, if I take a different audio file (something downloaded) and export it as raw 8 bit linear PCM at a similar sample rate and drop it into the sound rom, it sounds like loud static (mixed in with some silence basically matching the original sound levels). Yet if I export the imported real Simpsons sound it plays. So it seems like my process isn't fundamentally flawed but there seems to be something fundamentally different about the data. So I thought it might be a DC offset issue. I added just a tiny bit of DC offset to the original Simpsons sound and it sounded pretty awful. But I can't seem to adjust the DC offset to a point in my downloaded sound to get it to sound any better. I've tried removing the DC offset as well as adjusting it to match the slight DC offset in the original Simpsons sound, but it doesn't help.

Part of me wonders if something could be throwing MAME off, and perhaps if I burned a real rom and put it in my Simpsons machine it might work fine. But IIRC it's a masked rom that isn't socketed so I'm a little reluctant to go to the trouble of removing a non-socketed rom and soldering in a socket without any *real* reason to think it might work better.

Maybe I just need to sleep on it. But I'm open to ideas if anyone has any.



Sune
Connected
Reged: 09/21/03
Posts: 5648
Loc: Lagoa Santa, Brasil
Send PM


Re: MAME debugger question new [Re: TheShanMan]
#332748 - 10/04/14 06:50 AM


> if I take a different audio file (something downloaded) and export it
> as raw 8 bit linear PCM at a similar sample rate and drop it into the sound rom, it
> sounds like loud static (mixed in with some silence basically matching the original
> sound levels). Yet if I export the imported real Simpsons sound it plays.

It sounds like it should be possible to do that.

Maybe it has to match exactly in size?

S



AWJ
Reged: 03/08/05
Posts: 936
Loc: Ottawa, Ontario
Send PM


Re: MAME debugger question new [Re: TheShanMan]
#332757 - 10/04/14 11:54 AM


The K053260 PCM data is signed 8-bit. Make sure the data you're replacing it with is signed too.

Also, which sounds are you trying to replace? The character voices in simpsons are all ADPCM and not linear PCM.



R. Belmont
Cuckoo for IGAvania
Reged: 09/21/03
Posts: 9716
Loc: ECV-197 The Orville
Send PM


Re: MAME debugger question new [Re: TheShanMan]
#332765 - 10/04/14 05:18 PM


> It is indeed 8 bit linear PCM. I was able to pull the raw PCM into Audacity and it
> plays. However, if I take a different audio file (something downloaded) and export it
> as raw 8 bit linear PCM

Signed or unsigned?



TheShanMan
MAME Fan
Reged: 08/14/08
Posts: 8
Send PM


Re: MAME debugger question new [Re: AWJ]
#332771 - 10/04/14 07:02 PM


Sorry I know it's signed but forgot to mention it. Yes, it's the character voices. I guess ADPCM is close enough to linear PCM that it can be read as linear PCM and sound pretty accurate? It did sound slightly different when I imported the data into Audacity from the rom but it was so close that I chalked it up to different hardware handling it slightly differently.

Thanks for the suggestion - I'll see what I can do with ADPCM. First time trying to import the original sound data as ADPCM, it seems a little more distorted than it did with linear PCM but it's at least something to start playing with.

Thanks all for the input!

P.S. I haven't yet figured out how to find the exact start of a sound clip with whatever header info might be present (i.e. exactly how the sound chip reads and processes it) so I'm just working with the data raw. *Hopefully* that's not part of my problem but if I don't get very far going the way I'm going now, I'll switch my attention back to trying to understand what the sound chip is doing. My current approach *seemed* like the easiest way to get some success but maybe that was a flawed approach from the start.



AWJ
Reged: 03/08/05
Posts: 936
Loc: Ottawa, Ontario
Send PM


Re: MAME debugger question new [Re: TheShanMan]
#332772 - 10/04/14 09:43 PM


The ADPCM is a Konami custom format; it's not something you'll be able to encode to with off-the-shelf audio tools. It's a simple enough encoding that if you play back the data as signed 8-bit PCM you'll hear distorted but recognizable sounds, but that doesn't work the other way; if you try to play back actual 8-bit PCM data as Konami ADPCM you'll just get noise.

The "header" inside the sample ROM (the section with all the ASCII strings starting with KDSC) isn't actually used by the hardware or by the game software. The sample tables the game actually uses are in the Z80 program ROM. Only simpsons and vendetta even have that "header"; it's absent in other games using the same sound chip (like tmnt2)

Edited by AWJ (10/04/14 09:52 PM)



TheShanMan
MAME Fan
Reged: 08/14/08
Posts: 8
Send PM


Re: MAME debugger question new [Re: AWJ]
#332779 - 10/05/14 03:08 AM


I sure am glad to have come here because this would've been nothing but an exercise in frustration without your help. Much appreciated.

Do you understand the encoding at all? If it's a simple enough algorithm I could write a program to do the encoding for me, but of course without knowing the algorithm I'll certainly be out of luck.

Again, thanks for all the input and help. Even if I don't accomplish what I was trying to do, it's been fun and educational.



AWJ
Reged: 03/08/05
Posts: 936
Loc: Ottawa, Ontario
Send PM


Re: MAME debugger question new [Re: TheShanMan]
#332878 - 10/07/14 04:06 AM


Look at k053260.c in current SVN (I've just rewritten it to be closer to how the hardware presumably works and easier to understand--no more floating point math or one-letter variable names)



TheShanMan
MAME Fan
Reged: 08/14/08
Posts: 8
Send PM


Re: MAME debugger question new [Re: AWJ]
#332944 - 10/08/14 07:16 AM


Will do. Again, much appreciated.


Pages: 1

MAMEWorld >> EmuChat
View all threads Index   Threaded Mode Threaded  

Extra information Permissions
Moderator:  Robbbert, Tafoid 
0 registered and 331 anonymous users are browsing this forum.
You cannot start new topics
You cannot reply to topics
HTML is enabled
UBBCode is enabled
Thread views: 2850