Jump to content
Sign in to follow this  
MAGIK

Fixing Crystals MPU4 Fairground sound

Recommended Posts

With all this talk the other day about crystals sound ROMs it occurred to me there was a game I could look at. Crystal's Clone of JPMs fairground.  This is a cracking little MPU4 clone , but its still running on the same sound hardware as system 5 I think, so I thought to my self , what happens if I try and run the JPM system5 sound ROM with the crystal layout?

At first it didnt work.  I tried the 256k sound ROM file from JPM's fairground and got nothing. Mute machine, no samples.  In MFME the samples are sitting there and can be played, but the machine hardware , at least in emulated form, didnt play the sounds.

Im not about to give up though lol.  I wondered what would happen if I duplicated the file in HEX workshop so we had a 512k ROM image instead - lo and behold, it works!! well almost. The sound is alive, and its almost spot on , there are a couple of errors in the samples but if we can fix them, we have crystals fairground with working sound!!

The issue with it atm , is -

1) the dice reel plays the gamble lose sound.

2)Losing a gamble or feature plays "oooh thats fantastic"

3) the whoosh sound isnt there at all!

If we can get these issues fixed, then that'll be one less ROM to find!

 

Fairground Crystasoundfixedl.zip

Share this post


Link to post
Share on other sites

All sound ROMs for the NEC chip are the same format, the only differences would be the number of samples present and the sample data itself.

They all use the same upd7759 chip and the game code has no way of accessing the data on the ROM itself to check it unlike the YMZ280B

Share this post


Link to post
Share on other sites

Yeah I been reading 7759.cpp in the MAME source.  So to fix this,  I would need to find the relevant samples and move them around in the sound rom . Not easy!

Can you shed some light on how a particular sound sample looks like in the rom - I think there is a command part and a data part?

 

Share this post


Link to post
Share on other sites

If the samples are the same but in the wrong order, you can just change the lookup table at the beginning of the ROM

It would be a big job indeed actually changing or moving the sample data. Yes it has a command and data but the command part usually just specifies how many samples follow it and the rate.

Share this post


Link to post
Share on other sites

 Ahhh, I knew it had a look up table.  So there is a sample number and a relevant ROM address at the start of the ROM? See the mamedev page doesnt appear to talk about that!

 

Share this post


Link to post
Share on other sites

Ooooh my C++ is rusty. I cant appear to see the lookup table.  I will keep digging, need the user manual for the chip it doesn't appear to be out there.

 

Share this post


Link to post
Share on other sites
Posted (edited)

xx mm mm mm mm aa aa bb bb cc cc

where xx = number of tunes in the ROM

mm mm mm mm = magic number 5A A5 69 55 which is just a pattern of 1's and 0's as a ROM sanity check 0101 1010 1010 0101 0110 1001 0101 0101

aa aa = address of 1st sample hi byte lo byte

bb bb = address of 2nd sample hi byte lo byte

aa aa = address of 3rd sample hi byte lo byte

All addresses need to be multiplied by 2 for actual address in ROM

sample blocks start with ccrrrrrr where rrrrrr is the rate and cc is one of the following

00 silence or end of sample, next byte is silence length or 0 for no more samples

01 256 nibbles follow, no next byte

10    n+1 nibbles follow, n in next byte

11 repeat loop

yeah there is no manual available that explains this format

Edited by Wizard

Share this post


Link to post
Share on other sites

Magic number whats that??

Oh no I get it, its the header.

Thanks for the info!

I been having a little bit of fun there, I put the header into a program rom, 130 samples of white noise lol

Right, Im gonna have a fiddle with this, see if I can recode the lookup table for this to work!

 

Share this post


Link to post
Share on other sites
Posted (edited)

Im still missing something here. After the header we have 00 0B and the next entry along 1A 6D.  If I change 00 0B to 1A 6D, I dont duplicate samples 1 and 2, I just shorten the length of the first sample, so I am still screwing something up!

so is the first sample 000B x2 then second one 1A6D x2 and so on , are have I got that wrong way round?

Im well rusty lol

 

 

Edited by MAGIK

Share this post


Link to post
Share on other sites

This is driving me bandy.  If I enter 00 0B 1A 6D twice in the ROM where the look up table should be I can duplicate sample 1 but I get 256 samples of rubbish after

The duplicated sample appears as sample 3 instead, with the original sample 3 dissapearing. Where am I going wrong?  If I just change the first 4 bytes sample 1 dissapears and the rest of the samples are ok (changing just 00 0B to 1A 6D).  I must be messing with the wrong bytes!

 

sampleplay.jpg

Share this post


Link to post
Share on other sites
Posted (edited)

The 1st sample 00 0B is not shown in MFME as it's the stop code and played by setting the port to 0 on the NEC, I have no idea if you can put a real sample as the 1st ( none of the games we have use the 1st one, it's always blank ), it kind of suggests you enter code 0 to stop the current sample but all the games just reset the chip so I'm not sure if you can do that, the datasheet is ambiguous in that respect.

The 1st real sample begins at 1A 6D ( chip address 34DA ) and the 2nd is another blank 00 0B and the 3rd is a copy of the 1st

Some roms appear to have samples removed and that is done by simply replacing the entry with a copy of the 1st entry in the table 00 0B in this case

Edited by Wizard

Share this post


Link to post
Share on other sites
Posted (edited)

The original looks like this.  It doesnt matter if I move along to set the next two entries to 1A6D ,  I just get a 256 sample entry of nonsense.

Theres gotta be something we are missing.

 

sampleplay2.thumb.jpg.5f9042ac7c05001c8f4297cb1f0b0946.jpg

fairsnd.zip

Edited by MAGIK

Share this post


Link to post
Share on other sites

GRRRRRRRR!

Im lost here.  Ok, so all the ROMs I look at have 00 after the header so I ignore that and the byte after. But If I swap what I think is the addresses for samples 2 and 3 , I do swap them but I end up with samples 2 ,3 and 4 where 2 is what 3 used to be, 3 is the 256 samples garbage, and 4 is what 2 was!!

so 2 and 3 do swap, but you end up with an extra sound , and one of the samples in the ROM gets binned out.

anyone else fancy a go lol.

 

 

 

Share this post


Link to post
Share on other sites
Posted (edited)

I assume you mean it plays as intended in MFME but not on a real chip? or vice versa?

Edited by Wizard

Share this post


Link to post
Share on other sites

Vice versa.

Any ROM entry I change just seems to go to 256 samples and play nothing.

Im following the info from yourself and mame etc.  If I change the entry for sample 2 to sample 3 , sample 2 just goes to 256 samples in the sample viewer . Its almost like it doesnt allow you to change the sample addresses in the sound ROM.

say I swap the entrys 1A6D and 3B35 .  thats sample 1 (or 2, im not sure because MAME says it acts on the first sample) and 2 (or 3) .  The first sample gets wiped out.  And it doesnt matter where in the look up table I change the entries. if I change an entry it buggers off. 

Now heres where it gets weird.  If I duplicate sets of entrys,  (000B 1A6D 000B 1A6D)  I get sample one, then a junk entry (256 samples 0.04 seconds) and THEN a copy of the first sample in entry 3 lol.

See if you can figure it out bud,  I am trying to swap sample 38 for 39 , and sample 79 for 80.  I gotta be doing something wrong, or I am not changing the right bytes.
 

 

Share this post


Link to post
Share on other sites
Posted (edited)

ok , this is not going to be straight forward.

if you look at the image there, after a bit there is an address entry which appears to be 0000.  You can affect the samples changing the entrys before that, but it has no effect if you change the entries after?

The 0000 entry appears to be where the base address of sample 9 should be. Now,  when I change any sample, I get 256 samples of nothing before it  (If I change sound 8, sound 7 becomes 0.4 seconds of 256 samples, and sound 8 becomes whatever sample I am pointing at). but if I change anything after that 0000 address, nothing happens. I wonder if theres another header somewhere for the remaining samples?

I notice also -

you cant change sample 1 to anything other than what it is, it just dissapears.

Ive tried it with lots of different sound ROMs (for 7759) I keep getting the extra 256 sample sound entries when I make changes elsewhere.

 

 

sampleplay2.thumb.jpg.245355bfd898e0978639edbe96a2733a.jpg

Edited by MAGIK

Share this post


Link to post
Share on other sites
Posted (edited)

ok, I've looked at this again and here is the definitive answer

1st byte in ROM is the index of the last tune, so number of tunes is this value + 1

next 4 bytes is the magic number 5A A5 69 55 which is always the same

next is the lookup table, 2 bytes per entry and 1st byte * 2 bytes long, multiply by 2 for actual chip address

next is a padding byte

next is the start of the sample data for the tune pointed to by the first lookup table entry

tune data always seems to start with a zero

so to your ROM

07 = 8 samples ( lookup table is 16 bytes long )

5A A5 69 55 = magic number

00 0B start of sample 1 data = 0016

1A 6D sample 2 data = address 34DA

3B 35 etc

49 C8 etc

69 20 etc

8C 03 etc

8F 17 etc

CF 1C sample 8 data = address 19E38

00    padding

0053 start of tune 1 sample data ( pointed to by first table entry 00 0B above )

Forget what I was saying about a stop code, there isn't one, you just have to reset the chip

MFME cheats a little by making a silent tune 256 samples of silence so it can be played by the code and also assuming a tunes length is from its starting address to the address of the next tune which would explain your 256 entry because the address is less than the previous one

 

Edited by Wizard

Share this post


Link to post
Share on other sites

I get that, so how do we end up with 41 samples in total???

must be running it in slave mode afterward ?

 

Share this post


Link to post
Share on other sites

AHHHHH!  NOW I SEE !

the magic number repeats itself further up the rom ! theres more than one header!

I am still not quite understanding why you get a 256 sample sound entry after you change something tho!

 

Share this post


Link to post
Share on other sites

read my post again.

yes sometimes they page the ROMs and each has a complete table. When they flip ROMs you have to reset the chip as it seems to scan the header after reset

Share this post


Link to post
Share on other sites

yup can see that.  Still get the 256 sample thing tho. It seems to happen when you change a sample.

To explain, what I am doing here is using MFME and hex edit. I am changing a sample, and then reloading the layout in MFME to see the change. getting there ! if I can figure out how to stop it adding the extra 256 samples entry its a goodun!

 

Share this post


Link to post
Share on other sites
Posted (edited)

Post up another screenshot and I'll explain ( or try to lol )

By "changing" a sample, I presume you mean editing its table entry? You can't add any new ones because it will smash the start of the 1st samples data

Edited by Wizard

Share this post


Link to post
Share on other sites

with pleasure and thank you.

right, first screenshot - looking at the second page , starts at 20000h - can see the sample number and the magic number, then the addresses.  The sample I am I playing with is sample 10, not changed in this screenshot:

unchanged.thumb.jpg.6ec6b3c1ed66a4d0fef17e2f2c8b0cb2.jpg

 

Now, I am changing the location for sample 10 ( 00 F0) to 00 24 , to try and duplicate sample 9 as sample 10. But, when I do, sample 9 dissapears , like this :

 

9changedgets256.thumb.jpg.4af726f471907c9b4e060bfd623d1a85.jpg

 

See how sample 10 is a copy of sample 9 , but sample 9 has now gone missing and been replaced by what I can only think of as a dummy entry?

I am reloading the MFME layout each time, or pressing stop-start in the ROM loader to reboot the machine . So its the same as hard resetting real hardware.

My aim of what I am doing, is to replace a sample so that I can move samples 38 and 39 etc, without one or both of them being replaced by the dummy entry.

which is what seems to happen atm.

 

Share this post


Link to post
Share on other sites

ok that is happening because MFME works out the length of sample 9 as 0024 - 0024 = 0 and decides it's a blank entry whereas before it would have been 00F0-0024.

I can change the code to fix this but this a special case which is not found in real games where the addresses are always ascending

Share this post


Link to post
Share on other sites

ah right!  it seems to happen no matter where you change a sample tho. If I change sample 8 sample 7 becomes the dummy. Sometimes it adds a dummy after the sample you change.

 

Share this post


Link to post
Share on other sites
Sign in to follow this  

×