Secret of Mana - Changing the scrolling "dead zone"

Started by Binarynova, June 26, 2016, 08:49:23 PM

Previous topic - Next topic

Binarynova

Secret of Mana has a really large deadzone you can walk around before the game starts scrolling the map. This was likely done to accommodate having multiple players on the same screen at once. But in single-player it's more of an annoyance. You have to get so close to the edge of the screen for it to start scrolling that enemies appear right on top of you. So I'd like to shrink this dead zone to something a bit more reasonable (for single-player playthroughs).

I opened my Secret of Mana ROM (actually the VWF rom) in Snes9x-rr, and using some data from a RAM map and a little searching I found the values in RAM that represent the player's x and y coordinates relative to the screen. When you reach the point of scrolling, they stick to a particular value. So now I have those numbers:
0x38 to 0xC6 - horizontally
0x48 to 0xAD - vertically


In between those values the player moves freely. Hit those values and continue in that direction, and the map scrolls. Yay!

So, here's where my research breaks down. I don't know assembly, but I am a C# programmer, so I figured there must be a set of conditional statements in the ROM somewhere that have those values hardcoded. Something like:
if(hpos <= 0x38)
  scroll screen left
if(hpos >= 0xC6)
  scroll screen right
if(vpos <= 0x48)
  scroll screen up
if(vpos >= 0xAD)
  scroll screen down


So I guess my question is, am I even on the right track? Is it likely to be as easy as finding those 4 values relatively close together in the ROM with a simple hex editor?
#WoolseyDidNothingWrong

Dr. Floppy

It'll look something like:

if(hpos <= 0x38)
  scroll screen left

C9 39 00 (yes, 39)
B0 03
20 YY XX (where $XXYY is Scroll Screen Left subroutine)


if(hpos >= 0xC6)
  scroll screen right

C9 C6 00
90 03
20 YY XX (where $XXYY is Scroll Screen Right subroutine)


if(vpos <= 0x48)
  scroll screen up

C9 49 00 (again yes, 49)
B0 03
20 YY XX (where $XXYY is Scroll Screen Up subroutine)


if(vpos >= 0xAD)
  scroll screen down

C9 AD 00
90 03
20 YY XX (where $XXYY is Scroll Screen Down subroutine)



The 00's at the end of the first lines might not be present, depending on what mode the 65816 is in at that moment. Moreover, the final lines might be in the form of "22 ZZ YY XX", where $XXYYZZ is the longform address of the relevant subroutine.


Edit:
QuoteIs it likely to be as easy as finding those 4 values relatively close together in the ROM with a simple hex editor?

Ostensibly, yes. I'd search for the strings "C9 39"; "C9 C6"; "C9 49"; and "C9 AD". You just might pull this off quicker than you think!

zhade

I worked on fixing this thing too some time ago, I managed to make it work, but unfortunately there are messed up portions of maps which become visible when the screen start scrolling sooner and there is really no way to fix it other than editing the maps. its just a visual issue tho so if you dont mind it here is what I have in my notes about it:

-----------------Screen scrolling stuff--------------------

C0/D6CF - character block

C0/D962 - character block Y
   bra to C0/E70E ?
   
------

   defaultX : 38,C8
   
C0/D9AE   
   C0/D9D8 - max distance left
   C0/D9DD - max distance right

C0/D890
   C0/D902 - start scroll left
   C0/D909 - start scroll right

C0/D962
   C0/D994 - block right
   C0/D99B - block left

----

   defaultY : 48,B0

   C0DA63 - max distance down
   C0DA5E - max distance up

   C0D958 - start scroll down
   C0D951 - start scroll up
   
   C0DA1A - block down
   C0DA21 - block up

---


The edges positions are actually 38 and C8 for X and 48 and B0 for Y, but you were very close !
All you need to do is change the values at the addresses for "start scroll" left,right up and down
which should look like this:
C0/D902:   C93800

I never thought of searching for stuff in a ROM using the method you proposed, but it seems Dr. Floppy got it almost right, aside from the jsr (20) which comes later because the game does some stuff to cope with maps that can wrap-around , or check if the other characters are at a safe distance from the edge or... something :P But searching for C9 38 00 B0 would probably list a managable amount of matches so I kinda feel bad just throwing the answer at you instead of letting you find it by yourself because you did were on the right track after all. :-X

Binarynova

Thank you both for your help on this! I did spend some time yesterday searching using Dr. Floppy's help but never quite stumbled onto the right addresses.

Also no need to feel bad about giving it away zhade; before I just started entering values I did search for the string you suggested and there was only one match. ;)

I'm just glad I seemed to be on the right track; maybe there's hope for me in ROM hacking yet. :)
#WoolseyDidNothingWrong

Axiphel

Just saw this on the newest releases. I see it needs a headered rom. Aren't headers completely useless and from a time long since passed? I don't think I've ever had a rom that came headered.

zhade

Quote from: Axiphel on June 28, 2016, 04:11:46 PM
Just saw this on the newest releases. I see it needs a headered rom. Aren't headers completely useless and from a time long since passed? I don't think I've ever had a rom that came headered.
Are you sure you posted in the right thread ? I have no clue what you are talking about.. altho I think most of the roms available on the net do are headered, I dont really see the point of distributing non-headered roms.. Anyway, since headers are disposable, I guess you could just add some bytes to your ROM in order to make it work with a patch that requires a headered rom, then you could remove the "dummy" header

Axiphel

Quote from: zhade on June 28, 2016, 04:40:03 PM
Are you sure you posted in the right thread ? I have no clue what you are talking about.. altho I think most of the roms available on the net do are headered, I dont really see the point of distributing non-headered roms.. Anyway, since headers are disposable, I guess you could just add some bytes to your ROM in order to make it work with a patch that requires a headered rom, then you could remove the "dummy" header

This, which is what this thread is about, requires a headered rom. I've literally never gotten a rom that comes with a header and I've read that there is no point to a header anyway. Adding or removing a header is trivial. I was just wondering what the point for it is.

zhade

Quote from: Axiphel on June 28, 2016, 04:47:41 PM
This, which is what this thread is about, requires a headered rom. I've literally never gotten a rom that comes with a header and I've read that there is no point to a header anyway. Adding or removing a header is trivial. I was just wondering what the point for it is.

Oh sorry lol, I didnt know binarynova released it, It all makes sense now  :laugh: I guess since FusoYa's VWF requires a headered rom (it was released in the year 2000 after all) and binarynova wanted his patch to be compatible with it, so he made it use the same requirements I guess.

By the way, did you test with multiple players ?

Binarynova

When I originally was playing around with this I was using the VWF hack as a base because that's just how I intended to play it. At the time I didn't think really about releasing a hack.

Ideally I'd like to not require a header since I don't see the point of them either but I would like it to be compatible with the VWF patch. Is it unheard of to release a hack with two .ips files? One for headered and one for non-headered?

EDIT: Also I have not tested with multiple players, as this hack is intended for a single-player experience. The dead zone is almost certainly too small for multiple players to have an experience anything like the original game.
#WoolseyDidNothingWrong

dejan07

Thank you for this patch! I wanted to beg some hacker to do this for me but you did it.

SageOwl

I cannot seem to get this hack to progress past any point that requires it to scroll; it just instantly crashes the emulator/SNES. I've tried the Secret of Mana (USA).sfc rom, the pre-patched VWF rom, Secret of Mana (U) (!).smc, and even added a header to the SoM USA rom and still get crashes.

Does this require any specific rom aside from a headered one? If it's compatible with the VWF hack then it should run fine with the prepatched one.

Axiphel

I can't get it to work either but it doesn't crash. The screen just goes black as soon as I move. Patched over a clean headered rom and patched over the VWF hacked rom. Same results. Tried in both snes9x and bsnes-mercury.