Register | Login
Views: 19364387
Main | Memberlist | Active users | ACS | Commons | Calendar | Online users
Ranks | FAQ | Color Chart | Photo album | IRC Chat
11-02-05 12:59 PM
1 user currently in Rom Hacking: hukka | 2 guests
Acmlm's Board - I2 Archive - Rom Hacking - How I changed SMB1's Music Engine to that of another game. (lengthy post, ips included) | |
Add to favorites | "RSS" Feed | Next newer thread | Next older thread
User Post
bbitmaster

Koopa
Level: 18

Posts: 92/103
EXP: 25264
For next: 4633

Since: 03-28-04
From: Knoxville, tTN

Since last post: 12 days
Last activity: 7 days
Posted on 08-10-05 01:15 AM Link | Quote
I couple of weeks ago, I was reading something on the boards where some newbie that didn't know anything
wanted to change the music engine in SMB1 to some other game. Of course when I read this post I laughed
at first, but then I had a crazy idea. How hard _would_ it be for me to change a music engine in a game
and how long would it take? I've got tools available to me that no-one else has, and I really do have
the skill to do some amazing stuff to a nes rom, if I really want to. and I'm not afraid to show off
every now and then.

I'm also going to explain here exactly how I did it, and what tools I used

First, I asked a bunch of people in our little channel what game music they would like to see put with
smb1. My only restriction was that the game couldn't use the DMC channel, since that would require me to
place samples in the rom. Technically dmc COULD be done using the rom expansion method which I used, but
it would require a whole lot of code relocating, which I haven't got the time for.

Just on a whim Disch suggested duck tales 2. He said he liked the music and it'd probably go great with
smb1. So with no better ideas, I figured I would take a stab at placing the duck tales 2 music in SMB1.

One little problem was that if I stuck the duck tales 2 music engine in as it was it would obviously be
trying to read and write to the same RAM locations that SMB1 uses, since SMB1 uses almost all of the
normal ram ($0-$800). Having two programs using the same ram locations is obviously very disasterious.
What I needed was some way to get the duck tales 2 music engine completely disassembled so I could change
the memory locations that it used.

If I'd set out to do this a year ago, it would have been nearly impossible or atleast taken a heck of a
lot of work. But luckily, I've got a method to do this that no one else has yet.

See, Way back in january I set out to write a disassembler that could work with FCEUXD's code/data log
files to produce a nice formatted disassembly of any nes rom provided you play through every part of the
game. The disassembler which I named XDDasm turned into an almost complete disaster, I didn't plan it out
properly before I began coding it. This lead to me writing terribly messy code, and even hacking that code
up further when I ran into unexpected problems. I finally got it somewhat working, but not at all in a
releasable state. So for now It's going to remain locked up on my hard drive, atleast untill I get time to
completey recode it.

Anyway, neither FCEUXD, nor XDDasm works with NSF files yet. So I had to load up the duck tales 2 rom, and
somehow get it to play every tune in the game. So I could get all the related code and data logged into a
CDL file The game has no sound test, so I had to hack it to do this somehow. This proved very easy...
First, I found the offset of the play routine, then I got the main menu to play different tunes when I
pressed down on the dpad (where it normally changes menu options). And spent maybe 30 minutes to an hour
to get every bit of every tune logged.

Next, I ran this through my partially working XDDasm, and was suprised to find no bugs crept in. It worked
perfectly, and gave me a nice formatted disassembly of the duck tales 2 music engine! But I was still far from
done. I had to edit this disassembly, and do a lot of litle things such as map all of the jump pointer tables
to proper labels, since XDDasm can't do this (nor will it probably ever...).

After I got this disassembly edited up, I set it to use part of the expansion ram ($6300-$6400) ram for any
of it's ram needs. Then, to test it out, I assembled it and made an NSF out of it which played perfectly.

Now that I had a duck tales 2 music engine that is compatible with SMB1, I simply needed to get it in the game
somehow. My first step was to expand SMB1 and insert 4 extra banks (a bank being $2000 bytes big) and make it
use MMC3. Now, if anyone has noticed SMB1 is a pretty crammed rom, there isn't even enough room in it to insert
a bankswapping routine. This is where I got a really awesome idea for expanding it. What I would do is point
the reset vector to an empty bank, and simply dump most of the contents of that bank to expansion ram at
($6500-$7FFF) This makes extremely easy access code since it's right in the expansion ram. I also coded a loader
that bankswapped and lead to the duck tales 2 play routine. My banks were layed out like this.

bank 0: Reset vector points here - most of this bank gets copied to $6000-$7FFF
bank 1: duck tales 2 music engine here
bank 2: duck tales 2 music engine here
bank 3: garbage/unused. I don't really need this bank for anything, but the rom can't be expanded to a size without it
bank 4, 5, 6, 7: the normal SMB1 rom is here with a few modifications to call the music routine

Anyway, after coding and assembling bank 0, and packing it all together, and hacking smb1 to disable it's own
music, I got a perfectly working SMB1 rom that plays duck tales 2 music. There was a couple of problems though
First, the original SMB1 sound effects were all glitched up. There is no way to fix this that I know of,
since two sound engines are running at the same time, they will obviously interefere. But it doesn't really
matter, I accomplished my goal.

Now the other problem is (as disch informed me) that I pointed my reset vector to the swappable region at $8000
and I assumed bank 0 would be swapped in there at all times. Now this works great on most emulators, but you
can't assume anything is swapped in there on a real nes. So, at this point my hack wasn't really NES compatible.
And, of course I consider that unacceptable, just as I consider this thing where hackers use custom .pal files
unacceptable. If your hack won't play on the real system, then it isn't really a hack at all. It's something
else.

Luckily it would be fairly easy for me to fix this problem, since I have a TON of free space in my bank copied
over to the $6500-$7FFF region, all I need to do is move a peice of code or data out of SMB1's $E000-$FFFF
region over to my free space, and put a MMC3 init routine where that code or data was. Disch had already coded
a great MMC3 init routine and posted it in this thread

http://board.acmlm.org/thread.php?id=11936

He even got it down to 26 bytes. So all I need is 30 bytes, since I also need an SEI instruction, and a JMP $8000
to get to my bank 0.

To find something I could move to get 30 bytes, I looked at an old SMB1 disasembly that I had, and located a 48
byte section of data at E1FD with these 4 instructions referencing it

$E2B6:7D FD E1 ADC $E1FD,X
$E2BF:7D FF E1 ADC $E1FF,X
$E2CA:7D FD E1 ADC $E1FD,X
$E2D3:7D FF E1 ADC $E1FF,X

So this this was easier than I thought. all I had to do is move that 48 byte segment of data to, say $7F00-$7F30
and change these instructions to load from $7F00,x and $7F02, X

And of course put disch's mmc3 init routine in E1FD, and point the reset vector to it. I actually did all this in
the FCEUXD hex editor.

finally, the result was this

http://bitmaster.panicus.org/misc/smb1expirement/smb1dt2music.zip

That zip contains an IPS to be applied to an smb1 rom, which makes it play duck tales 2 music! Just press select to make it start playing and to change the tune!

also, heres some messy source code and notes on how to assemble and pack it together if you want to produce your
own smb1 rom with ducktales 2 music.

http://bitmaster.panicus.org/misc/smb1expirement/smb1expirement.zip
Just look at instructions.txt for a lengthy description of what to do.

I'd say that the whole thing took 8-10 hours to do... it might have taken several weeks without XDDasm.
AP

Panser
Level: 22

Posts: 4/333
EXP: 56817
For next: 1533

Since: 08-07-05

Since last post: 6 hours
Last activity: 6 hours
Posted on 08-10-05 04:57 AM Link | Quote
Wow! This is simply amazing. This is a truly wonderful piece of work! I played Japanese hacks with changed music, but changing the music engine.... You may have made a revolutionary step in ROM hacking and SMB hacking! I might use this in a future hack of mine despite the fact that the sound effects are messed up. Keep up the good work!


(edited by AP on 08-13-05 09:50 AM)
eNathan

Goomba
Level: 8

Posts: 10/33
EXP: 1773
For next: 414

Since: 08-07-05
From: United States, but does it matter?

Since last post: 1 day
Last activity: 8 days
Posted on 08-10-05 06:03 AM Link | Quote
Yea I would never dream of doing something which seems so advanced. Changing the music or gfx engine seems like an insane task to me, your ownage mate keep up the good work.
bbitmaster

Koopa
Level: 18

Posts: 94/103
EXP: 25264
For next: 4633

Since: 03-28-04
From: Knoxville, tTN

Since last post: 12 days
Last activity: 7 days
Posted on 08-13-05 06:39 PM Link | Quote
I thought I'd bump this thread, and post another hack I did a whole back, where I did something else crazy and completely replaced megaman 3's music engine with that of the little mermaid.

This hack was actually EXTREMLY easy to do as megaman 3 and the little mermaid use the exact same engine and everything. It only involved copying $4000 bytes straight from the little mermaid to megaman 3.

It is actually entirely possible (and VERY easy) to swap megamn 3 with megaman 4,5, 6, and several other capcom games as they all use the same music engine.

http://bitmaster.panicus.org/misc/Megman3withMermaidMusic.zip
hamtaro126

Shyguy
Level: 16

Posts: 42/83
EXP: 17272
For next: 2984

Since: 05-29-04
From: hacktown, USA

Since last post: 3 hours
Last activity: 1 hour
Posted on 08-13-05 09:09 PM Link | Quote
THAT WAS AWSOME!!! this is the greatest work i
have ever seen! of course, if i have the ducktales 2
nsf which dosen't exist! without it,
i can't change the music asm in the source
code to hebereke\ufouria music!!
drjayphd

Beamos
What's that spell?




pimp!
Level: 56

Posts: 1255/1477
EXP: 1387410
For next: 10766

Since: 03-15-04
From: CT

Since last post: 2 hours
Last activity: 2 hours
Posted on 08-13-05 09:25 PM Link | Quote
Schveeeeeet. But just out of curiosity, what's the upshot of the music engine for, say, the Little Mermaid vs. MM3?
Dish

Spiny
Level: 38

Posts: 522/596
EXP: 355646
For next: 14801

Since: 03-15-04
From: Disch

Since last post: 18 days
Last activity: 18 days
Posted on 08-13-05 09:36 PM Link | Quote
Hebereke/Ufouria is a Sunsoft game -- bbit's music swapping trick is done with Capcom games which share the same sound engine (in his posts he listed MM3-6 and Little Mermaid as examples). The music will not be interchangable with Sunsoft games (at least not in the same sense as his latest example) -- even some Capcom games won't work (older ones like MM2 which use a different music engine).

But even that aside -- Hebereke uses the DMC for the bassline... a trait common to many Sunsoft games. Capcom uses no DMC, and adding the DMC would be extremely difficult since you'd have to free up TONS of space in the upper PRG banks for DMC samples, and keep the same bank swapped in constantly.
Tanookirby

Bullet Bill
Level: 30

Posts: 467/509
EXP: 152637
For next: 13232

Since: 05-09-05

Since last post: 2 days
Last activity: 2 hours
Posted on 08-15-05 04:19 AM Link | Quote
Originally posted by hamtaro126
THAT WAS AWSOME!!! this is the greatest work i
have ever seen! of course, if i have the ducktales 2
nsf which dosen't exist! without it,
i can't change the music asm in the source
code to hebereke\ufouria music!!
Zophar's Domain has an NSF of the game available, but since the site is making some changes to its layout, you cannot access it. Try checking your PMs for the files.

BTW, the music patch for SMB is not working for me. Do I have to use a certain version of the game?
Googie

Surarok
Level: 39

Posts: 495/624
EXP: 380784
For next: 23987

Since: 03-15-04
From: Corona Queens New York

Since last post: 3 hours
Last activity: 3 hours
Posted on 08-15-05 04:26 AM Link | Quote
Originally posted by Tanookirby
BTW, the music patch for SMB is not working for me. Do I have to use a certain version of the game?


It worked fine for me, I used this version of SMB (Super Mario Bros (PRG 0) (JU).nes)
Tanookirby

Bullet Bill
Level: 30

Posts: 469/509
EXP: 152637
For next: 13232

Since: 05-09-05

Since last post: 2 days
Last activity: 2 hours
Posted on 08-15-05 04:33 AM Link | Quote
That is the same one I used. Still no music.
Dish

Spiny
Level: 38

Posts: 527/596
EXP: 355646
For next: 14801

Since: 03-15-04
From: Disch

Since last post: 18 days
Last activity: 18 days
Posted on 08-15-05 04:43 AM Link | Quote
You have to press select for the music to play.

*cough*readthepost*cough*
Bit-Blade
Pixel Artist

Level: 34

Posts: 327/445
EXP: 229264
For next: 24387

Since: 03-16-04

Since last post: 2 days
Last activity: 7 hours
Posted on 08-15-05 04:57 AM Link | Quote
Two simoultaneous music engines? That's quite an ingenious way to stick foreign music engines in rom. How much harder would it be to make the game exclusively use duck tales sound effects/music?

One thing I'm curious about... maybe it's just me but duck tales 2 music sounds remarkably like Little Samson, and slightly like T&C Surf Design 1.
Someguy

Buzzy Beetle
It seems as though the girl you've fallen for is also a pyromaniac.
Level: 32

Posts: 370/397
EXP: 193329
For next: 13113

Since: 03-15-04
From: I'm proud to be an American... I think...

Since last post: 1 day
Last activity: 5 hours
Posted on 08-15-05 06:14 AM Link | Quote
The only thing this needs now is for the commands in the original engine for changing music to be hooked onto the new engine. I noticed you didn't simply replace the old engine because some of the original songs such as the star and flagpole play while the Duck Tales 2 music plays...

EDIT: Also, you wouldn't happen to be able to tell me what 4000 bytes or whatever need to be changed to exchange music between compatable Capcom games? Just curious, it's kinda fun playing games with different music engines.


(edited by Someguy on 08-14-05 09:16 PM)
bbitmaster

Koopa
Level: 18

Posts: 96/103
EXP: 25264
For next: 4633

Since: 03-28-04
From: Knoxville, tTN

Since last post: 12 days
Last activity: 7 days
Posted on 08-16-05 08:52 AM Link | Quote
Bit-Blade & Someguy: yes, I could have hooked the original sound effect and music commands in this new engine, but I kind of got lazy. Also one little problem I had was that the duck tales 2 NSF rip, and the rip I did of it both seem to be missing their sound effects. I never really investigated into why this was so, but it would have to be fixed first.

Someguy: Yes, just search for the hex string "4C6C804CFE80A900" it should appear at the very beginning of the music bank. All you need to do is swap somewhere from $4000 to $6000 bytes starting at this hex string, and it should automatically play the other game's music.

Where it gets tricky is that some capcom games use 2 banks, or $4000 bytes for all of it, and some use 3 banks, or $6000 bytes, and it's hard to tell where it ends at, without special methods.

Megaman 3 happens to use around two and a half banks for all the music, then immeadieatly following that, it has some asm code related to something else - and that cannot be overwritten. The little mermaid used a smaller space to hold everything, and that made it really easy.

For a list of all the games that use this music engine see this post:
http://board.acmlm.org/thread.php?id=15172&ppp=20&page=0#257695
Just look at where I listed the games with the Vapcom "Takeru" music engine.

Anyway, good luck.
Add to favorites | "RSS" Feed | Next newer thread | Next older thread
Acmlm's Board - I2 Archive - Rom Hacking - How I changed SMB1's Music Engine to that of another game. (lengthy post, ips included) | |


ABII


AcmlmBoard vl.ol (11-01-05)
© 2000-2005 Acmlm, Emuz, et al



Page rendered in 0.019 seconds.