News: 11 March 2016 - Forum Rules

Author Topic: Mesen [NES game HD] I need to learn these things now  (Read 2657 times)

looks png

  • Jr. Member
  • **
  • Posts: 34
    • View Profile
Mesen [NES game HD] I need to learn these things now
« on: December 28, 2021, 12:17:27 am »
How to find the level code in the background picture?

How can background music find and edit IPS patches to define albums and tracks for them (and then adapt to simulator BGM instructions)?

My God, where can I find these teaching contents?

I don't seem to have found any information in this regard.

FAST6191

  • Hero Member
  • *****
  • Posts: 3554
    • View Profile
Re: Mesen [NES game HD] I need to learn these things now
« Reply #1 on: December 28, 2021, 03:26:51 pm »
I am not entirely sure what you are heading for here.

I am not sure what you mean by level code in the background picture. Can you give an example? I don't know if you mean level text, scrolling backgrounds, some kind of game where there is a foreground and background part of the level or similar.

Music on NES games is usually completely custom from the ground up, and can vary a bit if you head into some of the more exotic mappers and FDS stuff.
If you want to make it play different tracks you will have to take each game as it comes and work with that. Many ultimately could boil down to a pointer change or quick tweak of a command (if you can select tracks easily in a sound test screen, which many games could, then it is probably going to be this) but the trick is getting to that point. For the NES I don't really have an easy way of doing that without playing with assembly, which if you still don't care to even mess around with basic hex approaches is going to be right out. If you want to edit tracks you are probably still going to run into the need to program things (composes in the early home computers through 16 bit era were often accomplished programmers in their own right).
Or do you mean you want to make some kind of quasi NSF file (NSF files being what those emulators that play audio tracks from games are, them tending to be NES ROMs tweaked to leave the sound engine and and the sound with little else, or custom things from the ground up) such that your emulator knows to play a MP3 or something.

looks png

  • Jr. Member
  • **
  • Posts: 34
    • View Profile
Re: Mesen [NES game HD] I need to learn these things now
« Reply #2 on: December 29, 2021, 01:17:45 am »
I mean the background image, you know, like Mario's blue sky background.

I saw the high definition of contra, that is, there is only one picture outside the position where you can stand, which is much more convenient than modifying the background with tiles.

As for game music, I'm also looking for information about compilation

Jorpho

  • Hero Member
  • *****
  • Posts: 5261
  • The cat screams with the voice of a man.
    • View Profile
Re: Mesen [NES game HD] I need to learn these things now
« Reply #3 on: December 29, 2021, 02:02:35 am »
As for game music, I'm also looking for information about compilation
I have no idea what you mean about "compilation". Is there some other hack you know of that has replacement music?

(and then adapt to simulator BGM instructions)?

My God, where can I find these teaching contents?

I don't seem to have found any information in this regard.
Maybe it would help if you used the right terminology? I have no idea why you keep using the word "simulator". Mesen is an emulator. Have you ever seen anyone else call it a "simulator"?
This signature is an illusion and is a trap devised by Satan. Go ahead dauntlessly! Make rapid progres!

Bavi_H

  • Jr. Member
  • **
  • Posts: 39
    • View Profile
    • Robert Hart's Homepage
Re: Mesen [NES game HD] I need to learn these things now
« Reply #4 on: December 29, 2021, 09:09:36 am »
I am only a little bit aware of Mesen's "HD Packs" functionality, so I can't offer advanced help with it. But have you seen Mesen's HD Packs documentation? After taking a look at the documentation, here are some initial tips that might help you get started.

You can use the HD Pack Builder to make an initial hires.txt file, then experiment with editing the file. It gets put in the Mesen data folder HdPacks.

To use a background, it looks like you'd have to create a condition, a background tag, and then use them together.

To create an appropriate condition, you need to learn how to examine the memory of the game while it is running and find an appropriate RAM address that indicates the current level or screen. You'd probably use the Cheat Finder to start with to narrow down possible RAM locations. Then if you want, you can also use the Memory Tools RAM screen to further experiment with viewing, changing, or freezing prospective RAM addresses.

To replace the game's audio, you'll have to learn how the NES's CPU machine language and sound registers work, learn how to use the emulator debugger and breakpoints to find appropriate code in the game that is specifying sound tracks, then replace the game code with new code that writes to special addresses Mesen uses as a signal to start your external audio.

mkwong98

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Re: Mesen [NES game HD] I need to learn these things now
« Reply #5 on: December 29, 2021, 11:40:03 pm »
Adding to Bavi_H's answer:

Depending on the game, you can find which stage the game is running:
1. in RAM, which you need to using the debugger of the emulator to find and use the "memoryCheckConstant" condition in the hires.txt.
2. as tiles shown on screen, use the "tileAtPosition" condition to specify where and which tile you are looking for. 

To replace the audio, you need to know when the game is sending the music start signal and the music stop signal to the sound engine of the game, then you need hack the ROM to stop that process and send a signal to special registers which is recognized by Mesen. The emulator will pick up that signal and play a music file instead. Each game has its own sound engine so you have to study the game you are working on. You can check out the "Spotting Music Code" section of this doc. https://www.romhacking.net/documents/573/ and romhacking.net may have documents about the game you are working on which you can take a look too.

looks png

  • Jr. Member
  • **
  • Posts: 34
    • View Profile
Re: Mesen [NES game HD] I need to learn these things now
« Reply #6 on: December 30, 2021, 05:42:46 am »
I have no idea what you mean about "compilation". Is there some other hack you know of that has replacement music?
Maybe it would help if you used the right terminology? I have no idea why you keep using the word "simulator". Mesen is an emulator. Have you ever seen anyone else call it a "simulator"?

Another hdnes seems to replace audio. I'll take the time to try it

The simulator is mesen, which is an excellent simulator. Unlike hdnes, it can only be made. It feels terrible to play

December 30, 2021, 05:44:07 am - (Auto Merged - Double Posts are not allowed before 7 days.)
I am only a little bit aware of Mesen's "HD Packs" functionality, so I can't offer advanced help with it. But have you seen Mesen's HD Packs documentation? After taking a look at the documentation, here are some initial tips that might help you get started.

You can use the HD Pack Builder to make an initial hires.txt file, then experiment with editing the file. It gets put in the Mesen data folder HdPacks.

To use a background, it looks like you'd have to create a condition, a background tag, and then use them together.

To create an appropriate condition, you need to learn how to examine the memory of the game while it is running and find an appropriate RAM address that indicates the current level or screen. You'd probably use the Cheat Finder to start with to narrow down possible RAM locations. Then if you want, you can also use the Memory Tools RAM screen to further experiment with viewing, changing, or freezing prospective RAM addresses.

To replace the game's audio, you'll have to learn how the NES's CPU machine language and sound registers work, learn how to use the emulator debugger and breakpoints to find appropriate code in the game that is specifying sound tracks, then replace the game code with new code that writes to special addresses Mesen uses as a signal to start your external audio.

It looks very complicated. I'll study it hard, but I'm really not very interested. I just want to have a tool to complete it directly

December 30, 2021, 05:46:18 am - (Auto Merged - Double Posts are not allowed before 7 days.)
Adding to Bavi_H's answer:

Depending on the game, you can find which stage the game is running:
1. in RAM, which you need to using the debugger of the emulator to find and use the "memoryCheckConstant" condition in the hires.txt.
2. as tiles shown on screen, use the "tileAtPosition" condition to specify where and which tile you are looking for. 

To replace the audio, you need to know when the game is sending the music start signal and the music stop signal to the sound engine of the game, then you need hack the ROM to stop that process and send a signal to special registers which is recognized by Mesen. The emulator will pick up that signal and play a music file instead. Each game has its own sound engine so you have to study the game you are working on. You can check out the "Spotting Music Code" section of this doc. https://www.romhacking.net/documents/573/ and romhacking.net may have documents about the game you are working on which you can take a look too.

I'm trying to replace music with hdnes audio function, but I don't have much time now. To be honest, I don't understand these programming work

Jorpho

  • Hero Member
  • *****
  • Posts: 5261
  • The cat screams with the voice of a man.
    • View Profile
Re: Mesen [NES game HD] I need to learn these things now
« Reply #7 on: December 30, 2021, 12:25:31 pm »
The simulator is mesen, which is an excellent simulator. Unlike hdnes, it can only be made. It feels terrible to play
Do you understand that emulator is a different word from simulator? I am quite sure no one calls these programs "simulators"!

If you insist on referring to things with the wrong words, then yes, you are going to have a difficult time finding the information you need!
This signature is an illusion and is a trap devised by Satan. Go ahead dauntlessly! Make rapid progres!

mkwong98

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Re: Mesen [NES game HD] I need to learn these things now
« Reply #8 on: December 30, 2021, 11:11:38 pm »
Do you understand that emulator is a different word from simulator? I am quite sure no one calls these programs "simulators"!

If you insist on referring to things with the wrong words, then yes, you are going to have a difficult time finding the information you need!
I think English is not his/her mother language and the posts are machine translated, that is why all the terms are changed.

Another hdnes seems to replace audio. I'll take the time to try it

The simulator is mesen, which is an excellent simulator. Unlike hdnes, it can only be made. It feels terrible to play

December 30, 2021, 05:44:07 am - (Auto Merged - Double Posts are not allowed before 7 days.)
It looks very complicated. I'll study it hard, but I'm really not very interested. I just want to have a tool to complete it directly

December 30, 2021, 05:46:18 am - (Auto Merged - Double Posts are not allowed before 7 days.)
I'm trying to replace music with hdnes audio function, but I don't have much time now. To be honest, I don't understand these programming work
Music/sound on the NES is very primitive and every game does it differently, so either someone else has worked it out for you or you have to learn programming to know which music is being played. The idea behind HDNes replacing audio is more or less the same as Mesen, and it doesn't support the use of conditions in the HD pack, so I won't recommend using that. It is possible for Mesen to replace audio without hacking the ROM using LUA script. The downside is that Mesen doesn't automatically load game specific LUA scripts, so you have to load the script manually each time you play that game.


looks png

  • Jr. Member
  • **
  • Posts: 34
    • View Profile
Re: Mesen [NES game HD] I need to learn these things now
« Reply #9 on: January 03, 2022, 10:19:18 pm »
English is really not my mother tongue, although I know something. However, there is a lack of professional terminology
Well, because I changed Mario's protagonist, I hope to use another BGM to set off the game atmosphere, so starting music by myself is also an option (I've seen other games that replace music, and I really need IPS files to describe how to replace it, but I don't know how to make instructions and codes). If I can't replace music, I can turn it off. Or where can I find Mario music patches made by experts? I can replace it with an Ogg file that matches the protagonist.

mkwong98

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Re: Mesen [NES game HD] I need to learn these things now
« Reply #10 on: January 05, 2022, 12:19:03 am »
I did some work on Super Mario Bros a long time ago, so I'll give you some tips:

1. According to this document: http://www.romhacking.net/documents/345/,
The RAM range $00f0 to $00ff are used for audio related settings. In particular $00f4 and $00fb from that range are used for primary music.

2. And this document http://www.romhacking.net/documents/630/ tells you what the values stored in those location represent:
Code: [Select]
$F4: Area Music.
(Values:
$00: No area music.
$01: Overworld
$02: Underwater
$04: Underground
$08: Castle
$10: Cloud
$20: Pipe Intro
$40: Starman
$80: Music paused, this can only be found during debug, when the game routine is not finished)

So you can check which line in the code writes to one of those addresses and change it to write to the special addresses recognized by Mesen. You can do this either by hacking the ROM and save the changes into a IPS file or by writing code as LUA script and manually loading the script when playing.

The script may look something like this:
Code: [Select]
function playMusic(address, value)
  if value == 1 then
    emu.write(0x4105, 0, emu.memType.cpu)
    return 0
  else
    return value
  end
end

emu.addMemoryCallback(playMusic, emu.memCallbackType.cpuWrite, 0xFB)

This is all I know about the music in this game. I haven't worked out how to handle the speed/tempo changes when the timer goes below 100.
 

looks png

  • Jr. Member
  • **
  • Posts: 34
    • View Profile
Re: Mesen [NES game HD] I need to learn these things now
« Reply #11 on: January 12, 2022, 06:11:09 am »
Sorry, there have been a lot of things recently, so I didn't come up

It's great to have these materials. In addition, my main concern is how to make IPS? Do you use fceux?

How to make it recognized and used by mesen?

mkwong98

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Re: Mesen [NES game HD] I need to learn these things now
« Reply #12 on: January 12, 2022, 06:55:50 am »
If you use the debugger in Mesen, you can save your changes to the ROM as IPS directly:
https://www.mesen.ca/docs/debugging/debugger.html#how-to-edit-code

And Mesen can load IPS automatically with correct settings:
https://www.mesen.ca/docs/configuration/preferences.html#misc-settings

I haven't hack game code before, so I don't know what other tools are available and how useful they are.

looks png

  • Jr. Member
  • **
  • Posts: 34
    • View Profile
Re: Mesen [NES game HD] I need to learn these things now
« Reply #13 on: January 15, 2022, 08:41:37 am »
Hi, master, I found another problem:

When Mario eats flowers in the dark, ff0c3c1c in the character's flashing palette does not seem to be replaced with new HD tiles. Where should this situation be modified?

However, ff0c3c1c has been replaced in ff162718. I mean, it is normal in the sun, but not in the dark, such as in the sewer or at night
« Last Edit: January 15, 2022, 08:48:28 am by looks png »

mkwong98

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Re: Mesen [NES game HD] I need to learn these things now
« Reply #14 on: January 17, 2022, 10:44:36 am »
Looks like I missed this palette in my pack. With my Graphics Pack Editor, select Mario, click the "Palette swaps" tab, you should see 3 entries at the top. Add one more entry with ff0c3c1c,ff163027 as the new palettes.

looks png

  • Jr. Member
  • **
  • Posts: 34
    • View Profile
Re: Mesen [NES game HD] I need to learn these things now
« Reply #15 on: January 18, 2022, 02:08:51 am »
Mario's tile maps have a total of 7 groups, all increased? Because the first group ff162718 has added ff0c3c1c, while the other 6 groups have not

mkwong98

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Re: Mesen [NES game HD] I need to learn these things now
« Reply #16 on: January 18, 2022, 06:20:44 am »
Only need to add to the first one

looks png

  • Jr. Member
  • **
  • Posts: 34
    • View Profile
Re: Mesen [NES game HD] I need to learn these things now
« Reply #17 on: January 18, 2022, 10:25:21 am »
I have a look again. The above entry itself has what you call ff0c3c1c, ff163027, which itself exists

I don't understand

This problem should exist in the file I sent you last time. If you are free, can you have a look?
« Last Edit: January 18, 2022, 10:47:36 am by looks png »

mkwong98

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Re: Mesen [NES game HD] I need to learn these things now
« Reply #18 on: January 19, 2022, 10:10:14 am »
Sorry, I was wrong. It should be ff1c3617, ff163027

looks png

  • Jr. Member
  • **
  • Posts: 34
    • View Profile
Re: Mesen [NES game HD] I need to learn these things now
« Reply #19 on: January 19, 2022, 09:09:56 pm »
Oh, yes, that's the code. The problem has been solved successfully!

Then I just need to adjust the tile content. It's perfect

Well, the only thing left is the audio. I have to study for a while. I really don't understand the data from finding the code to establishing the connection with mesen until it is successfully applied to the HD package...