News:

As a consequence of the forum being updated and repaired, the chatbox has been lost.
However, you can still come say hi on our Discord server!

Main Menu

Exit editing, a Map Code Hex tutorial

Started by Atrius, 20, November, 2010, 11:17:24 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Atrius (He/Him)

With the addition of the Hex editor for map code, you can do a lot of neat new stuff if you know how.  Today I'm gonna show you how to edit where you end up when exiting an area.




I'm going to be working on the flooded map of Dalia.
The first step is to find out where the data for the exits is at.  Lucky for us the editor has a data pointer detection algorithm that scans the code of the function that loads it, and finds it for us.  Under the "Code Pointers" section of the Map viewer we can see what the editor found neatly organized under it's parent function.  Unfortunately for us it looks like we have 2 sets of data for exits, so how do we tell which one we want?



Next we'll switch over to the "Code Hex" section to take a look at that data.  I've outlined each set of data in red in the image, so let's find out which one is what we want.  In this case the code data is actually used for multiple maps, and each has it's own exit data.  For separating them the first value of each block of exit data (outlined in yellow) is going to be the key.  Essentially this value just says which map the data actually applies to.   Since we're looking at map 10, which translates to 0xA in Hex we want the data at 0x02009018.  The next step is to find out exactly which exit defined in the data we want to edit.



Opening up the game in VBA, I actually walked through the exit I wanted to edit, the Sanctum in Dalia in this case.  Next I took a look at the value at 0x02000420 (0x02000400 if you're editing the original Golden Sun) in VBA's memory viewer. 0x0001000C, the first four digits tell us the entrance we entered, and the last four tell us which map it is.  Taking this back into the editor...



...we find our corresponding data entry here, 0x1070100C.  This value can be broken up as such: 0xABBCCDDD where the values at C correspond to to the entrance, and the D's will correspond to the map this exit takes us to.  The A is unidentified as of yet, and B identifies which exit it on the map it is.  We won't go too deep into this value since there's not much we can do with it, but suffice it to say that it corresponds with an event index used in the tile data for the map that the game checks to tell when the player walks into that exit.  Anyway, back to editing our exit, we now need to find a new place we want it to take us to.



We could use the same technique I used to find the values for Dalia's Sanctum, but I wanted to demonstrate another method.  Here I used a debug menu I found a while back.  The values you use in this menu correspond directly to what you would actually use in your edit (Don't forget to convert them to hex though)



Back in the Hex editor, I replace the old map value with the one for the credits in this case.  A quick save, and reload of the game in VBA later, and...



...now when I walk into Dalia's Sanctum the credits begin to roll as if I beat the game.
[sprite=220,4,0]I'm shaking my head in general disapproval of everything[/sprite]

Daddy Poi's Oily Gorillas

That is interesting... Now, will the second part be based on X and Y locations? My best guess is to assume that it is the "Some entrances?" pointer. (It makes sense that similar data would be close together, after all.) Golden Sun seems to separate the data too much, it seems...

Quote from: TriviaOn the subject of M&L: Superstar Saga, the X and Y locations (both from and to) as well as the map to go to, are all together. (I call them non-scripted warps.. I have also looked into M&L's warp scripts as well which are pretty much similar to their non-scripted way, if I remember correctly, it's been awhile since I looked at it.)
Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)

Atrius (He/Him)

As the title suggests, that only sometimes contains some of the entrance locations  (It's common to only see only 1 entrance defined there for a map that has closer to a dozen).  The rest of them are stored elsewhere in the ROM (outside of the map's data) for no apparent reason.  So yes, Golden Sun does separate the data too much, even to the point of ridiculousness in some cases.  That's where you enter areas anyway, for the exits their locations are in the tile data for the map.

[sprite=220,4,0]I'm shaking my head in general disapproval of everything[/sprite]

Daddy Poi's Oily Gorillas

#3
Hmm... This data looks similar to how some other things in the game work.

0xABBCCDDD = The A is actually boolean, and it says if we have a flag value. (The FFFFFFFF on the right.)

Basically, what I'm getting is that if it were not FFFFFFFF, and it was, for example, 0000000F, it'd read flag 0x00F in storybook flags. If it is off, exit to this room, if it is on, continue reading the exit data... It looks like either way you are going to warp somewhere

I have a feeling you would need to do something similar to this, if you did use flag values: (Example.)

1070200B 0000000E //Warp to one room if this flag is off.
1070100D 0000000F //another room if this one is off, and the other is on.
1070100C FFFFFFFF //Where the last one is FFFFFFFF. The final destination room.

Notice how all three have the 07? That's the exit we are dealing with, and now with this new discovery, it makes sense why we have it here.

Oh yeah, and I think 00000000 and FFFFFFFF are the same?
Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)

Daddy Poi's Oily Gorillas

I'm now going to add that the first ??? in the Map Pointers has to do with changing the coordinations and size of the exits. These are normally used with exits on ladders.

I'll do Hesperia Settlement as an example. (217:14)

0200A380 | 02A0 002E 0190 02B0 003E 01A0 FFFF 000E
0200A390 | FFFF 0000 0000 0000 0000 0000 0000 0000

02A0 002E 0190 are the X Z Y start coords of the exit.
02B0 003E 01A0 are the X Z Y end coords of the exit.
FFFF is a flag, obviously.
000E is the entrance number, ofcourse. (Note the 217:14 from earlier.)
Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)

Jiten

Quote from: Teawater on 20, June, 2012, 05:36:43 PM
I'm now going to add that the first ??? in the Map Pointers has to do with changing the coordinations and size of the exits. These are normally used with exits on ladders.

I'll do Hesperia Settlement as an example. (217:14)

0200A380 | 02A0 002E 0190 02B0 003E 01A0 FFFF 000E
0200A390 | FFFF 0000 0000 0000 0000 0000 0000 0000

02A0 002E 0190 are the X Z Y start coords of the exit.
02B0 003E 01A0 are the X Z Y end coords of the exit.
FFFF is a flag, obviously.
000E is the entrance number, ofcourse. (Note the 217:14 from earlier.)

So you're saying that coordinates are only located through the coding?

Daddy Poi's Oily Gorillas

Quote from: Ixion on 20, June, 2012, 07:12:35 PM
Quote from: Teawater on 20, June, 2012, 05:36:43 PM
I'm now going to add that the first ??? in the Map Pointers has to do with changing the coordinations and size of the exits. These are normally used with exits on ladders.

I'll do Hesperia Settlement as an example. (217:14)

0200A380 | 02A0 002E 0190 02B0 003E 01A0 FFFF 000E
0200A390 | FFFF 0000 0000 0000 0000 0000 0000 0000

02A0 002E 0190 are the X Z Y start coords of the exit.
02B0 003E 01A0 are the X Z Y end coords of the exit.
FFFF is a flag, obviously.
000E is the entrance number, ofcourse. (Note the 217:14 from earlier.)

So you're saying that coordinates are only located through the coding?
Quote from: Atrius on 21, November, 2010, 12:54:20 AM
As the title suggests, that only sometimes contains some of the entrance locations  (It's common to only see only 1 entrance defined there for a map that has closer to a dozen).  The rest of them are stored elsewhere in the ROM (outside of the map's data) for no apparent reason.  So yes, Golden Sun does separate the data too much, even to the point of ridiculousness in some cases.  That's where you enter areas anyway, for the exits their locations are in the tile data for the map.


I haven't exactly looked into the tile data, so...
Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)

Atrius (He/Him)

#7
They're not defined explicitly as coordinates.  The tile data is an array with information for EVERY tile, so the tiles that are an exit just have a byte set with the index of the exit they represent (The value outlined in yellow in the second screenshot in the first post).  It get's decompressed, and loaded to 0x02010000 while the game is running.

@Teawater, that's not the only place entrances are defined, in fact very few of them are there.  It seems the rest are stored with the data that also contains the treasure data, which gets decompressed to 0x0202E000.  The first two bytes are a SHORT that tells the location where the entrance data begins there.  It's formatted a little differently as well.

Each entry is only 6 bytes.

BYTE = Entrance index
USHORT = X coordinate
USHORT = Y coordinate
BYTE = Direction the player faces

[sprite=220,4,0]I'm shaking my head in general disapproval of everything[/sprite]

Daddy Poi's Oily Gorillas

#8
All this is quite interesting. A lot of places where similar stuff is defined. A bit complicated to take in every case without being familiar with the data.

Quote@Teawater, that's not the only place entrances are defined, in fact very few of them are there.
Actually, my guide was to altering the exit coordinates inside the tiles which have them. (Helpful for placing a condition on the Z coordinate.)

This is pretty much a gist of what I have:
= Tile data: Define exit locations in tilemap. (I'm going to look into this in a bit.)
= Exits: Which entrance to warp to
= "Ladder-specific exits": (What I recently found) ; It seems you can only get the "breakpoint" in SDL-H if you are on the tile that has the exit. (When breakpointing on the data itself... if I remember from my research the other day.) Is this the only place where the Z-coordinate of an exit is checked?
= Entrances: Coordinates and direction.



QuoteThe rest of them are stored elsewhere in the ROM (outside of the map's data) for no apparent reason.
This is something I want to look into, but unfortunately, I don't have an example yet, so it might take a bit.



Off-topic: I like how the seventh pointer (The second ??? in the GS editor's Code Pointers list.) in the map code has to do with map tile mods (Both solidity and graphic tiles.) I'll have to look into this a bit more later on.  It all seems to be pure asm code, though.
Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)

Rolina

What about non-traditional exists, such as cyclone points?  Or do those count as just your basic exit?

Daddy Poi's Oily Gorillas

#10
It seems they are listed in the exits as well.

I'm not sure how they require the cyclone psynergy yet, but I assume the data for that is located elsewhere.

Obviously, changing where you are warped to will work a lot like the debug menu does. I mean, depending on the entrance you warp to, the cyclone won't necessarily lay you down, but you could just appear there.

So, just think of this exit data being entrance to exit connectors and nothing more. ; I wonder if it is worth looking at the tile data(?) (Or somewhere else) to find out how it requires cyclone, though? ; As well as how an entrance can have a cyclone drop you off?


I also want to know where the data is that determines what transition graphics you get when switching between rooms. I saw a few unique ones just by going through the rooms using the debug menu.
Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)