News: 11 March 2016 - Forum Rules

Author Topic: Mesen for Graphics Editing?  (Read 1459 times)

hseiken

  • Jr. Member
  • **
  • Posts: 3
    • View Profile
Mesen for Graphics Editing?
« on: January 12, 2022, 11:31:52 pm »
First off, forgive me for asking maybe a noob question as I've not really done ROM hacking outside of making dumb graphics edits years ago in Nesticle (remember those days?).  I do understand somewhat abstractly how hex works, etc. but what I'm being baffled by is a problem of finding specifics of elements I want to change.

One of the first problems I thought I could somehow muscle through and figure out was how to look at where nametables are loaded in order to do some kind of meaningful edits of a cut scene, but came up short.  Another edit I tried to figure out was change some minor physics (i.e. jump height, speed, etc.).  I was able to locate the actual location of speed, but not track down where things like 'max speed' and 'accelleration' were located in ROM. 

I use these examples because, in my unexperienced mind at least, they seem like generic edits anyone would want to mess with and good minor tasks to ask if there's a tutorial for Mesen that allows hunting data like this by tracking them down from RAM into ROM because this seems to be not nearly as easy at is seems.

Maybe there's better tools for doing this?  I don't know, but it seems Mesen's debugging tools are pretty robust, but I suppose they're only as useful as the user's ability to use them!

Thanks for any help and pointing me towards any examples of using Mesen to track down data in ROM that's desireable to edit. 

Thanks for any help and I apologize if this is a question that is answered over and over.  I did a few searches not only for Mesen but also for the specific game I'm attempting to defile and didn't seem to find anything I was looking for.

mkwong98

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Re: Mesen for Graphics Editing?
« Reply #1 on: January 14, 2022, 12:40:11 am »
Have you tried setting breakpoints to trap writes to a specific memory location?
https://www.mesen.ca/docs/debugging/debugger.html#breakpoint-configuration

Beware the values you are looking for may not exist as actual value in ROM. For example, acceleration can be done by using the INC instruction instead of using ADC with the acceleration value.

hseiken

  • Jr. Member
  • **
  • Posts: 3
    • View Profile
Re: Mesen for Graphics Editing?
« Reply #2 on: January 14, 2022, 06:57:21 pm »
Are there any tips for identifying a relevant breakpoint?  Maybe specific example might be something that can help me sort this out.  I'm trying to brute force my way to finding the relevant ROM location for just changing player speed, but I feel like I'm circling what I should be finding instead of spiralling inward and ultimately homing in on it.

So in the memory viewer, I moved the character around looking for something that looks like speed, i.e. it ramps up and then levels off and coincides both left and right.  In this case, I found multiple parts in ram that use the exact same values (my guess is that the main player is made up of multiple sprites which *seems* like it would be why, but I don't actually know!)

Those memory addresses in CPU RAM were
$004C, $0406, $0C06, $1406, $184C and the last one I felt like writing down was $1C06 before I realized I probably only need one of these for any use.

Next, I noticed a pattern that $..4C and $..06 repeated in all of these. 

At this point, I decided to go hunt through the debugger for just 4C and 06, which put up a bunch of stuff, none of it jumped out at me even after trying to edit those locations in the ROM just to see what happens, so I went back and searched out #06 and #0C.  I found stuff for #06, but again, I crashed the game doing any memory changes on the '=' side of the line more often than not.

And finally, at wit's end, I looked at the number of reads from ROM, paying attention to something that was constantly being read or corresponded to me pressing left or right on the controller.  After some blind looking around, I centered on ROM address $1EB18.

However, I'm not even sure I found anything actually useful as when I change values, it seems to, and I'm guessing, not change speed, but change JMP and JSR for various player interactions.  I found one value that seems to skip checking for maximum movement speed but only for one direction, another one seemed to alter normal platforms to slippery ones, etc. 

So I've stumbled onto *something*.  How might I use this information to more smartly pin down the values I'm actually looking for which is character accelleration and character maximum speed?  Surely there's a methodology to do this.  Keep in mind I know how programming works and can look at it in an abstract way to understand flow control, setting values, etc. but I'm not exactly super familiar with assembly, nevermind specific assembly for specific CPUs. 

At any rate, thanks for any help.  I'm trying to learn the process itself rather than ask for specific help with the game I'm hacking with so that I actually come away with a moderately useful skillset in any future hacks I might fancy doing.  (and yes, I've looked up the specific game for documentation etc. but nothing I was hunting for seems to be documented, at least on this site).

mkwong98

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Re: Mesen for Graphics Editing?
« Reply #3 on: January 15, 2022, 12:44:16 am »
The Cheat Finder under Cheats tool is a good way to find RAM addresses. Let's use 1943 as an example. I change the plane's horizontal movement by pressing and holding the left or right button. At this point, I set "Previous value was" to "Not equal" and press "Add Filter", this will narrow down the list of addresses. Also use the "equal" filter when horizontal movement is not changed to narrow down the list further. Repeat until only a few values are left. I get 00F4, 00F6, 0401, 040B, 040C. Then set one of those RAM addresses to a fixed value to see which one affects the game. And it turns out 0401 holds the combined horizontal and vertical movement direction. I right click Breakpoints list in the Debugger and add a breakpoint on read to CPU Memory at Specific Address $0401 and I got the address D7F9. From here I need to see how that value being read is converted to actual movement of the plane.


hseiken

  • Jr. Member
  • **
  • Posts: 3
    • View Profile
Re: Mesen for Graphics Editing?
« Reply #4 on: January 15, 2022, 09:47:43 am »
Thanks, that sounds pretty straight forward so I'll give it a shot (pun!) to find various values.  As I said, I am interested in learning the process itself.  There's another thing I edited graphics wise in which my new graphic doesn't line up with where the player's bullet spawns (it looks like it's flying out of their face instead of the gun...so the original graphic it looks good, but now it's hilariously bad!), etc.  I feel like I'd be here every other day asking roughly the same question, so I appreciate your example, I think it'll help me a lot..now to go look at more abstracted walls of numbers again.   8)

tygerbug

  • Full Member
  • ***
  • Posts: 107
    • View Profile
Re: Mesen for Graphics Editing?
« Reply #5 on: April 13, 2022, 11:21:39 pm »
  Personally, I prefer Mesen's tools for looking at what the ROM is doing, but for editing the hex code, I like to use FCEUX. You can edit in real time as the ROM is playing, and find stuff in the code through trial and error. I'm not an expert but I can fumble my way through a hack this way.

   You can turn the FCEUX Code/Data Logger on and off and it will highlight data which has been used in the ROM during the time it was on.

   When you look at the nametables in Mesen, you can see which tiles are displayed, one after the other. In many cases you can type in a short string of tiles that are displayed next to each other, and see if this string appears in the ROM hex, to find the scene for editing.
« Last Edit: May 06, 2022, 02:33:37 pm by tygerbug »

pianohombre

  • Sr. Member
  • ****
  • Posts: 375
    • View Profile
    • My personal website of short stories and comics
Re: Mesen for Graphics Editing?
« Reply #6 on: May 06, 2022, 02:02:40 pm »
Mesen is a good utility for hd graphics packs. It really polishes up games to make them 16-bit quality (or better). I wish it was easier to find hd packs available rather than having to search for games individually on google and hope for a hit.
"Programming in itself is beauty,
whether or not the operating system actually functions." - Linus Torvalds