Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - Disable SMS FM sound

Reply to topic
Author Message
  • Joined: 26 Sep 2017
  • Posts: 5
Reply with quote
Disable SMS FM sound
Post Posted: Wed Sep 27, 2017 3:18 pm
2 questions about the Sega Master System FM sound.

1 - I have the Japanese Master System (with the FM unit built-in to the console), and I would like to know if its possible to disable the FM. I mean something simple, like turn on the console with 1+2+up or something like that. I like the FM sound, but some games I prefer the PSG sound.

2 - I will get a Master Everdrive, (I have a adapter to play sms games). So is it possible to patch roms to disable the FM sound? I know that there is something like a flag in the header of each game that will check if the system have the FM unit. So I was thinking to edit this flag to always says that there is no support.... so, I could copy 2 folders in the SD card.. one with FM, other without FM sound.

I tried to contact ValleyBell to ask him, but without success.
  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 13389
  • Location: London
Reply with quote
Post Posted: Wed Sep 27, 2017 3:21 pm
Last edited by Maxim on Wed Sep 27, 2017 4:53 pm; edited 1 time in total
1. No
2. Yes, but I think there isn't a handy set of patches for you to use. Maybe we can build them in this thread. The method is to find the FM detection code and force it to say no.
  View user's profile Send private message Visit poster's website
  • Joined: 26 Sep 2017
  • Posts: 5
Reply with quote
Post Posted: Wed Sep 27, 2017 4:45 pm
Maxim wrote
1. No
2. Yes, but I think there isn't a handyvset of patches for you to use. Maybe we can build them in this thread. The method is to find the FM detection code and force it to say no.


Thanks for the information. Do you know if the FM detection code is different in each game? If the answer is no, we can create a universal patcher. Thats why I tried to contact ValleyBell.. at least in his sonic hack, he could find this code and put "yes".
  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 13389
  • Location: London
Reply with quote
Post Posted: Wed Sep 27, 2017 4:55 pm
No, but there will be common patterns, so it will not take long for an experienced person to do for each game. I believe there are a bunch of patches on the Everdrive forums to force FM mode on modded export systems; this is similar.
  View user's profile Send private message Visit poster's website
  • Joined: 15 Sep 2009
  • Posts: 375
Reply with quote
Post Posted: Fri Sep 29, 2017 9:24 am
I took the FM detection code from Phantasy Star, which is on the wiki and modified it slightly for Sonic 1 FM.

You can probably detect the code safely if you search for the bytes that are generated from the ASM code of the first loop.
-:  ld a,b
[...]
+:  djnz -

The code that follows handles the result of the test:
    ld a,c
    cp 7               ; Check test was passed 7 times out of 7
    jr z,+             ; <-- jumps of test is successfull
    xor a              ; If not, result is 0 <-- test fail, disable FM
+:  and 1              ; If so, result is 1

You can disable FM by replacing the jump instruction ("jr", bytes $18 xx) with two NOPs ($00 $00).

It should be fairly easy to write a small tool that searches for the byte patterns and replaces the one instruction. Figuring out the byte patterns themselves should be easy if you throw the FM detection routine into a Z80 assembler and print a listing file that lists instructions + the resulting byte codes.
And it probably works for all games that use the SMPS sound driver.


ashramkun wrote
I tried to contact ValleyBell to ask him, but without success.
Well, I don't visit SMSPower often enough to reply within 12 hours.
  View user's profile Send private message
  • Joined: 26 Sep 2017
  • Posts: 5
Reply with quote
Post Posted: Fri Sep 29, 2017 2:31 pm
Thanks alot Maxim and ValleyBell for all information.

I will try this weekend. I had basic ASM at college, but it isn't a language that I normally use. I did some test using the tutorial here for SMS roms and looks like isn't that hard.

Is SMS Examine the best dissembler?

Quote
Well, I don't visit SMSPower often enough to reply within 12 hours.

I did not say it as a complain. SMSPower was the only place that I could find a way to contact you, once Sonic Retro never validated my account. You don't have any obligation to answer me. Thanks again =)
  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 13389
  • Location: London
Reply with quote
Post Posted: Fri Sep 29, 2017 3:52 pm
I'd debug in Meka, with an IO port breakpoint, then hot patch to test. You can probably do the same in Emulicious, which can also emit a disassembly like SMS Examine but better.

It'd always better to ask this kind of question in public anyway, you get more answerers, less pressure on the individual and it remains for others to find in the future.
  View user's profile Send private message Visit poster's website
  • Joined: 26 Sep 2017
  • Posts: 5
Reply with quote
Post Posted: Tue Oct 03, 2017 11:22 am
Hello again
So far, I could:

1- Debug the code and find where and what should I change. Just changed a value to 0 at it worked on Meka.
2 - Disassembler the rom (using SMS Examine and/or Emulicious).
3 - I know where and how to change the code.

BUT, I am having problems to compile the code. I can't even compile the code unchanged from SMS Examine and/or Emulicious.

For example, I am using Kenseiden, and I got these erros:




Just for test, I changed some values to skip these errors, and I could compile a "working" sms file. Working means: The game could be load, but bugged.

Did I miss something? Should I be able to compile a unchanged code?
  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 13389
  • Location: London
Reply with quote
Post Posted: Tue Oct 03, 2017 11:48 am
Better to avoid recompiling and instead binary patch. Overwrite the start of the detection function with the "return no" code, it will avoid affecting the rest of the ROM. Recompiling with modified code is actually incredibly hard.
  View user's profile Send private message Visit poster's website
  • Joined: 14 Apr 2013
  • Posts: 538
Reply with quote
Post Posted: Tue Oct 03, 2017 12:36 pm
ashramkun wrote
Should I be able to compile a unchanged code?

Yes but there was a bug in Emulicious about naming the binaries.
An update fixing this issue has just been launched.

ashramkun wrote
1- Debug the code and find where and what should I change. Just changed a value to 0

In Emulicious, you can save the changes you've made in the Memory Editor directly either as a patched ROM or an IPS patch.
  View user's profile Send private message Visit poster's website
  • Joined: 26 Sep 2017
  • Posts: 5
Reply with quote
Post Posted: Tue Oct 03, 2017 4:26 pm
Success!

Quote
Better to avoid recompiling and instead binary patch. Overwrite the start of the detection function with the "return no" code, it will avoid affecting the rest of the ROM. Recompiling with modified code is actually incredibly hard.


Quote
In Emulicious, you can save the changes you've made in the Memory Editor directly either as a patched ROM or an IPS patch.


I could create a IPS using Emulicious and it worket! Now I can create a noFM romset to put in my Everdrive.

Thanks again for all information!
  View user's profile Send private message
  • Joined: 28 Mar 2002
  • Posts: 177
  • Location: Toronto, Canada
Reply with quote
Post Posted: Sun Sep 20, 2020 3:00 am
ValleyBell wrote
I took the FM detection code from Phantasy Star, which is on the wiki and modified it slightly for Sonic 1 FM.

You can probably detect the code safely if you search for the bytes that are generated from the ASM code of the first loop.
-:  ld a,b
[...]
+:  djnz -

The code that follows handles the result of the test:
    ld a,c
    cp 7               ; Check test was passed 7 times out of 7
    jr z,+             ; <-- jumps of test is successfull
    xor a              ; If not, result is 0 <-- test fail, disable FM
+:  and 1              ; If so, result is 1

You can disable FM by replacing the jump instruction ("jr", bytes $18 xx) with two NOPs ($00 $00).

It should be fairly easy to write a small tool that searches for the byte patterns and replaces the one instruction. Figuring out the byte patterns themselves should be easy if you throw the FM detection routine into a Z80 assembler and print a listing file that lists instructions + the resulting byte codes.
And it probably works for all games that use the SMPS sound driver.


ashramkun wrote
I tried to contact ValleyBell to ask him, but without success.
Well, I don't visit SMSPower often enough to reply within 12 hours.


I've found another way which basically involves disabling the writes to port $f2. If we search for the byte pattern "D3 F2", which is [out ($f2),a] and replace it with NOPs we also get the same result. There are usually 2 write operations to this port on each game that i've checked and they are close by in the ROM.
  View user's profile Send private message
Reply to topic



Back to the top of this page

Back to SMS Power!