Castlevania 1 - "turning off" the music

Discuss NSF files, FamiTracker, MML tools, or anything else related to NES music.

Moderator: Moderators

Post Reply
User avatar
Mr.Babs
Posts: 1
Joined: Thu Jun 01, 2017 10:53 am

Castlevania 1 - "turning off" the music

Post by Mr.Babs »

Hello everyone. My goal is to have an NES ROM file of Castlevania 1 that plays normally, minus the music. The SFX would still play however, so simply turning off the sound channels or muting the game does not produce the desired result. Why would I want this? For video making purposes, and I suppose game music bands might find it useful as well. A couple of examples:

https://www.youtube.com/watch?v=o6iRuyeE3ug&t=782s Link to the Past (please don't share this one. the gameplay is so bad LOL. mainly just a proof of concept.)
https://www.youtube.com/watch?v=qRGNrjs0vXo Gradius II
https://www.youtube.com/watch?v=oG900fADjVg Dracula X

In the past I've been lucky with games like Link to the Past and MegaMan 1-3 which have level editors that allow you to do this, however the best CV level editor, Stake, does not. Instead it has a pointer, which looks like you can just swap the songs around, but not to nothing. It does have an Advanced Editing Mode that shows you three sound channels and 3 values. Example for stage 1:
Square 1: 9C83
Triangle: 9DB5
Square 2: 9D18
but I don't know what to do with this information and you seem unable to change their values. There is a glitch in the game that let's you play stage 1 without music, but only lasts until the boss, and there's a Game Genie code that turns off the SFX only, so that's no good LOL. There is a Castlevania ROM map here:
http://datacrystal.romhacking.net/wiki/ ... ia:ROM_map
but sadly lists nothing about music. So if anyone can offer some advice on tools, or pointers on how to approach the problem, that would be splendid. I'd like to eventually have a catalog of "Silent Games". Thanks for reading.
User avatar
B00daW
Posts: 586
Joined: Thu Jan 03, 2008 1:48 pm

Re: Castlevania 1 - "turning off" the music

Post by B00daW »

NOP

Code: Select all

MODE           SYNTAX       HEX LEN TIM
Implied       NOP           $EA  1   2
the ST_ opcodes that point to APU registers with 16-bit little endian addressing (MSB last/LSB first):

Code: Select all

MODE           SYNTAX       HEX LEN TIM
Zero Page     STA $44       $85  2   3
Zero Page,X   STA $44,X     $95  2   4
Absolute      STA $4400     $8D  3   4
Absolute,X    STA $4400,X   $9D  3   5
Absolute,Y    STA $4400,Y   $99  3   5
Indirect,X    STA ($44,X)   $81  2   6
Indirect,Y    STA ($44),Y   $91  2   6

MODE           SYNTAX       HEX LEN TIM
Zero Page     STX $44       $86  2   3
Zero Page,Y   STX $44,Y     $96  2   4
Absolute      STX $4400     $8E  3   4

MODE           SYNTAX       HEX LEN TIM
Zero Page     STY $44       $84  2   3
Zero Page,X   STY $44,X     $94  2   4
Absolute      STY $4400     $8C  3   4
Use a breakpoint system in an emulator to decode the indirect address writes to APU properly.
Last edited by B00daW on Sat Jul 01, 2017 1:25 pm, edited 1 time in total.
User avatar
dougeff
Posts: 3078
Joined: Fri May 08, 2015 7:17 pm

Re: Castlevania 1 - "turning off" the music

Post by dougeff »

I'll look at it. I did this for another game once.
nesdoug.com -- blog/tutorial on programming for the NES
User avatar
nesrocks
Posts: 563
Joined: Thu Aug 13, 2015 4:40 pm
Location: Rio de Janeiro - Brazil
Contact:

Re: Castlevania 1 - "turning off" the music

Post by nesrocks »

Setting 0x48D to 60 mutes all sounds, so I'm thinking that the only way would be to set all music pointers to a "mute" sfx (one by one).
https://twitter.com/bitinkstudios <- Follow me on twitter! Thanks!
https://www.patreon.com/bitinkstudios <- Support me on Patreon!
Bavi_H
Posts: 193
Joined: Sun Mar 03, 2013 1:52 am
Location: Texas, USA
Contact:

Re: Castlevania 1 - "turning off" the music

Post by Bavi_H »

Here is what I came up with:

Code: Select all

Tested with

MD5: 756170ba1e06fa26c60d10114dc6a5ae  Castlevania (USA)
MD5: 728e05f245ab8b7fe61083f6919dc485  Castlevania (USA) (Rev A)


.NES File Offset  Bank  PC Address  Compare  Value  Game Genie  Description
----------------  ----  ----------  -------  -----  ----------  --------------------------
698               00    8688        F0       50     ASEEATEY    mutes melodic notes
646               00    8636        F0       70     AYUATTEY    mutes one drum sound
64A               00    863A        F0       70     AYUEZTEY    mutes the other drum sound
Process I used:
  • The APU registers link reminded me the sound registers start at 4000.
  • Using breakpoints on writes to 4000, I found the general area of the music code.
  • From the romhacking.net links, I found a document about the music format: http://www.romhacking.net/documents/150/
    This helped me identify what certain comparison values in the code were likely for (drums E9 and EA and rests C0).
  • I googled for the 6502 instruction set to refresh myself with it and found this document's section on branches helpful: http://www.6502.org/tutorials/6502opcodes.html#BRA
    It suggested using a comparison with the overflow flag as a way to force or prevent a branch.
  • I modified the compares for the drums to always fail (F0 BEQ to 70 BVS) and modified the compare for the rests to always succeed (F0 BEQ to 50 BVC).
Tools: I used the tools below that are built into the emulator FCEUX. I don't have time to explain how to use these tools in detail, but if you're interested, maybe the help file can get you started.

Debug menu:
  • Debugger
  • Hex Editor
  • Game Genie Decoder/Encoder
Tools menu:
  • Cheats
Hex Editor window:
  • View menu: ROM File
  • File menu: Goto Address
Last edited by Bavi_H on Sat Jul 01, 2017 6:00 pm, edited 1 time in total.
ccovell
Posts: 1045
Joined: Sun Mar 19, 2006 9:44 pm
Location: Japan
Contact:

Re: Castlevania 1 - "turning off" the music

Post by ccovell »

Nice job with the GG codes.

If you can hack the game ROM, try this:

Using a hex editor, hack the following locations in the headered PRG1 ROM:
at 0x1c1bd in the ROM:
20 F0 FF
at 0x20000 in the ROM:
C9 26 90 02 A9 00 8D F6 07 60

This code silences music code numbers 27 and above.

[edit] some caveats:
The game code seems to rely on the music code taking its time to play out, eg. in the death tune, so when you die, it'll quickly restart play.
Music codes after 27 include some sound effects, so separating them all out is a more involved hack.
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Castlevania 1 - "turning off" the music

Post by tepples »

So if the game played the conjectured full version of the dying jingle, it'd be even more annoying, right?

Source
ccovell
Posts: 1045
Joined: Sun Mar 19, 2006 9:44 pm
Location: Japan
Contact:

Re: Castlevania 1 - "turning off" the music

Post by ccovell »

Look, it's not an effective in-joke if you need links in triplicate.... :x
Bavi_H
Posts: 193
Joined: Sun Mar 03, 2013 1:52 am
Location: Texas, USA
Contact:

Re: Castlevania 1 - "turning off" the music

Post by Bavi_H »

ccovell wrote:The game code seems to rely on the music code taking its time to play out, eg. in the death tune
Yeah, I ran into that too. In my initial attempt, I identified a place in the code that seemed to be reached for music only and just changed it to RTS. But when you die, the game never proceeds:

Code: Select all

.NES File Offset  Bank  PC Address  Compare  Value  Game Genie  Description
----------------  ----  ----------  -------  -----  ----------  -------------------------------
5D2               00    85C2        A5       60     AVKAZISZ    disable music (stalls on death)
User avatar
Bregalad
Posts: 8055
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Re: Castlevania 1 - "turning off" the music

Post by Bregalad »

You don't even need to do any modification to the game ; just watch the first 2 demoes scenes (but not the 3rd) then press start.

The music would still start at a boss fight, though, and I'm pretty sure the music resumes when you reaches level 2.
Post Reply