Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2011-04-10 06:35:38

Miksy91
Member
Registered: 2010-10-16
Post 320/2,339

Map Connection Editing

Map connection data is stored in the end of the Secondary Map Header.
It contains of 1 + 12x bytes of which the first determines whether the map has connections or not.
A map connection to each side consists of eleven bytes so if the map would be connected to two sides, the map connections would consist 25 bytes (1 + 12 * 2).

Now, I'm going to show you what New Bark Town (Outside) map's connection data looks like.

$94E1C
03 (West + East)
18 03 F0 52 30 C7 09 1E 00 3B 42 C7 (West)
18 02 BD 72 3D C7 09 28 00 00 2F C7 (East)



Connection Byte:
    00 = No Connections
    01 = East
    02 = West
    03 = West + East
    04 = South
    05 = South + East
    06 = South + West
    07 = South + West + East
    08 = North
    09 = North + East
    0A = North + West
    0B = North + West + East
    0C = North + South
    0D = North + South + East
    0E = North + South + West
    0F = North + South + West + East


Structure:
~~~~~~~~~~
#1: [Bank of the connected Map]
#2: [Number of the connected Map]
#3-4: [Pointer to "Connection Strip"s Upperleft Block (Connected Map)]
#5-6: [Current Map Position]
#7: ["Bigness"]
#8: [Map Width]
#9: [Y Alignment]
#10: [X Alignment]
#11-12: [Window]


Current map position

North: C703 + X Movement of Connection Strip
South: C700 + (Height of Map + 3) * (Width of Map + 6) + X Movement of Connection Strip
West: C700 + (Width of Map + 6) * (Y Movement of "Connection Strip" + 3)
East: C6FD + (Width of Map + 6) * (Y Movement of "Connection Strip" + 4)


Window

North: C701 + [Height of connected map] * [Width of connected map + 6]
South/East: C707 + [Width of connected map]
West: C706 + 2 * [Width of connected map]


Explanations:
~~~~~~~~~~
For each of these explanations, I'm going to use the data of West connection.


Pointer to "Connection Strip"s Upperleft Block (Connected Map)
The pointer is F0 52.
Now, open map of Route 29 with a map editor and check the offsets of the trees that are located in the upper-right corner of the map.
The one of the upper-right corner is in offset 0xA92F2 in ROM and so the one in 0xA92F0 is two blocks away from it.
You've got to make the game point to offset of this kind when you're making a connection to west.


Current Map Position
In this case:
C700 + (A + 6) * (0 + 3) = C730 (and by rotating the bytes around, you get 30 C7)


"Bigness"
Width of the connection in the connected map


Map Width
Width of the connected map


Y Alignment
Relative Y-position of player after entering connected map.

Connection |
Direction  | Formula
___________|_______
North: (Height_of_connected_map * 2) - 1
South: 0
West/East: (Y_movement_of_connection_strip_in_blocks * -2)


In this case, this is set to 00 because New Bark Town's upper-left corner is "at the same height" as Route 29's upper-right one.


X Alignment
Relative X-Position of player after entering connected map.

____________________
Connection |
Direction  | Formula
___________|_______
North/South: (X_movement_of_connection_strip_in_blocks * -2)
West: (Width_of_connected_map * 2) - 1
East: 0

In this case, just basically: 1E * 2 - 1 = 3B


Window
C706 + 2 * 1E = C742 (and by rotating the bytes around, 42 C7)



P.S
I recommend using JohtoMap v. 1.02 to edit the connections because it can edit all of the bytes properly.

Last edited by Miksy91 (2012-07-04 14:18:47)

Offline

#2 2011-06-03 17:29:52

Miksy91
Member
Registered: 2010-10-16
Post 379/2,339

Re: Map Connection Editing

This tutorial is going to be updated soon as I'm getting the hang of editing map connections (have completed two connections (both to N-S and W-E) of which another actually begins in the middle of the map (not at the upper-corner)). Still having a little trouble with this but it shouldn't take too long to figure out how this really works.

Besides, just saying that editing map connections is far from impossible ;)
It just requires planning and using brains :D

Last edited by Miksy91 (2011-06-03 17:35:36)

Offline

#3 2011-06-22 05:02:02

Cloud
Member
Registered: 2010-12-18
Post 271/302

Re: Map Connection Editing

Miksy wrote:

X Movement of Connection Strip =
Y Movement of Connection Strip =

Hmm... I forgot this part. " X/Y movement of connection strip". Can someone give the in-game example value for this? Thanks

Offline

#4 2011-06-23 18:39:49

Miksy91
Member
Registered: 2010-10-16
Post 425/2,339

Re: Map Connection Editing

I'm not sure if this is right but this is what I've written about them in my pc.

X Alignment = The left border where the connection begins in the connected map
X Movement of Connection Strip = The left border where the connection begins in the "starting map"


Easiest way of connecting two maps into each other would be so that both of them have the same x-size (up-down connection) or same y-size (left-right).
Then, you wouldn't have to mess around with "X Alignment" and "X movement of connection stip" values.
However, in other situations, you've just gotta figure out the right values.

Last edited by Miksy91 (2011-06-23 18:55:01)

Offline

#5 2011-06-24 00:24:17

Cloud
Member
Registered: 2010-12-18
Post 273/302

Re: Map Connection Editing

Can't you give a specific answer, my friends? Like ecrutreak X movement of connection strip is FF or something. Goldenrod Y movement of connection strip is 0F or something. I really appreciate your answer, my friends. So Thanks alots.

Offline

#6 2011-06-24 05:24:54

Miksy91
Member
Registered: 2010-10-16
Post 427/2,339

Re: Map Connection Editing

Cloud wrote:

Can't you give a specific answer, my friends? Like ecrutreak X movement of connection strip is FF or something. Goldenrod Y movement of connection strip is 0F or something. I really appreciate your answer, my friends. So Thanks alots.

Those aren't related to the place you are.
For example, Ecruteak city's "Y Movement of Connection Strips" are different for both west and east.

Last edited by Miksy91 (2011-06-24 05:31:36)

Offline

#7 2011-06-24 07:30:16

Cloud
Member
Registered: 2010-12-18
Post 274/302

Re: Map Connection Editing

That's not what i mean.

Cloud wrote:

X Movement of Connection Strip =
Y Movement of Connection Strip =

This is, I don't understand what this mean and where i can get this value from. I only need 2 exact value for this as an example and i will figure the rest out.

Last edited by Cloud (2011-06-24 07:36:15)

Offline

#8 2011-06-24 10:10:36

Miksy91
Member
Registered: 2010-10-16
Post 428/2,339

Re: Map Connection Editing

Well it's hard to be explained and I thought of doing so earlier today...
Anyways, I'll post an example of it now.

The map connection data of Olivine City (Up).

Height = 10
X Alignment = 246
Y Alignment = 35

246 refers to 256 - (5 * 2) which tells the game at which block the map connection begins in Route 39.
The last block (the block in the bottom-right corner) of Route 39 is in offset 0xAB69A and is a tree block.
Last block: 256, second last: 254, third last: 252...and notice that 246 refers to tile 01 in offset 0xAB695.
So the "starting point" where Olivine's map connection leads in Route 39 is offset 0xAB695.

The "height" or "Bigness" of the connection is 10 (0xA) blocks.
Because the connection is only 6 blocks in Route 39, the game reads Border Blocks from Route 39, maybe ???

Current Map Position in this case is C708 --> X Movement of Connection Strip = 8

...

To tell you the truth, I've no idea how that value could be 8 in this case.
I tend to figure the right value often by trying - if you've other values right you can figure out why you see right blocks in wrong parts of the map (blocks are either for example 5 bytes ahead). Then, you'd just have to probably change current map position by 5.

Offline

#9 2011-06-24 11:43:25

Cloud
Member
Registered: 2010-12-18
Post 275/302

Re: Map Connection Editing

Oh, thanks alot. I just think of something more efficient on doing this! ;D

Offline

#10 2011-07-22 11:30:56

rockyrojas88
Member
Registered: 2011-01-23
Post 43/46

Re: Map Connection Editing

Suppose I change the height of route 22 from 9 to 14,
what would I have to do using map editor so Viridian city connects correctly?
(I'm using johtomap, or should I use gold map?).

Last edited by rockyrojas88 (2011-07-22 12:03:44)

Offline

#11 2011-07-22 16:40:24

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 839/3,578

Re: Map Connection Editing

Well Goldmap does not support map connections, so JohtoMap is fine. I don't really use JohtoMap (the old version left a bad taste in my mouth, so I haven't shifted to the new version yet) But I figure you would just work out the values using the formulas Miksy listed, but plugging in your new height value instead of the old one the same as you would if you were editing them manually.

Offline

#12 2011-07-22 16:53:38

rockyrojas88
Member
Registered: 2011-01-23
Post 44/46

Re: Map Connection Editing

Yeah, but I didn't quite get the formula.. :/

Last edited by rockyrojas88 (2011-07-22 16:54:23)

Offline

#13 2011-09-02 21:39:51

pokeman
New member
Registered: 2011-09-02
Post 1/1

Re: Map Connection Editing

Could you go over how to edit map connections in Johtomap? Thank you:)

Offline

#14 2011-09-03 20:47:08

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 956/3,578

Re: Map Connection Editing

I  don't use Johtomap, but maybe someone else can.

Offline

#15 2012-05-28 05:42:47

kanzure
Member
From: Austin, Texas
Registered: 2012-01-15
Post 9/19
Website

Re: Map Connection Editing

Most of those formulas are wrong. Let me explain what works for me. I call the three pointers as follows: strip pointer, strip destination pointer, and window pointer. You can see the source code to Pokémon Crystal here, where you will also find examples of each of these connection types.

strip pointer north:
a) connected_blockdata + (connected_map_height * connected_map_width) - (connected_map_width * 3)
b) connected_blockdata + (connected_map_width + xoffset + (16 * connected_map_height) - 16)
c) there's one map in crystal that i don't know
d) just "connected_blockdata" never happens in gsc

strip pointer south:
a) connected_blockdata
b) connected_blockdata + (xoffset - connection_strip_length + current_map_width) / 2)
c) connected_blockdata + ((xoffset - connection_strip_length + current_map_width) / 2) - 1)
d) just "connected_blockdata" never happens in gsc

strip pointer east:
a) connected_blockdata
b) connected_blockdata + (connected_map_height - connection_strip_length) * connected_map_width)
c) connected_blockdata + (100 - 4 * connected_map_width)
d) connected_blockdata + (2 * (100 - 4 * connected_map_width))

strip pointer west:
a) connected_blockdata + (((connected_map_height - current_map_height) * connected_map_width) - (connected_map_width * 3) + (connected_map_width - 1) - 2)
b) connected_blockdata + (connected_map_width - 3)
c) connected_blockdata + (xoffset + (current_map_height * 2))
d) there's at least one map i don't know
e) "connected_blockdata" is never used in gsc, apparently

Now, strip destination.

strip destination north: $C703 + x_movement_of_the_connection_strip_in_blocks
strip destination south: $C703 + x_movement_of_the_connection_strip_in_blocks + ((current_map_height + 3) * (current_map_width + 6))
strip destination east: no clue, tauwasser's stuff doesn't work, lin's stuff doesn't work
strip destination west: no clue, tauwasser/lin have failed me, nothing works with the data

window north: $C801 + ((connected_map_height * 6) + (connected_map_height * connected_map_width))
window south: $C807 + connected_map_width
window east: $C807 + connected_map_width
window west: $C807 + xoffset

Thank you.

Last edited by kanzure (2012-05-28 05:51:34)

Offline

#16 2012-05-28 13:09:52

Tauwasser
Member
Registered: 2010-10-16
Post 279/452

Re: Map Connection Editing

Before saying that Lin or me have failed you, you should make sure you understand the documentation properly.

What impact do your formulas for "strip pointer" really have? None. The pointer depends on where on the map the connection is to be made, which depends on the map design and what the designers thought looked good, not on some static formulas depending upon the width and the height of the map...
Heck, I could rewrite those formulas using birth dates and whether or not 1876 was a leap year... They would have about the same meaningfulness as your formulas!
Of course, this value has to be in the range of [connected_blockdata, connected_blockdata + (connected_map_height) * (connected_map_width) - 1], i.e. inside the map, but that should have been clear. Actually, you could make it point to something different in the same ROM bank and try to fool the system that way. But that would not work out as the blocks aren't (visibly) reloaded on map change.

For strip destination you didn't point out any examples that don't work. However, I assume you didn't check the formulas thoroughly, or else you would have noticed that the RAM address where blockdata starts is actually 0xC800 for Crystal, not 0xC700 as for Gold/Silver. So there is no way you observed north/south connection strip destination pointers that match your equations.

The whole matter is quite simple and I suggest you draw a diagram for the block data of the current map including the border and go from there. You'll immediately see that the above formulas given by Miksy are indeed valid once you adjust for the start offset change.
Your windows also seem suspiciously wrong, as the xoffset cannot have any impact on the window, since this is after map change.

cYa,

Tauwasser

Last edited by Tauwasser (2012-05-28 13:12:36)

Offline

#17 2012-05-28 15:20:11

Miksy91
Member
Registered: 2010-10-16
Post 888/2,339

Re: Map Connection Editing

Tauwasser is right although I must admit this tutorial should really be made more clear.
The problem is that I still have to struggle with connections myself to make them work (frequently, I test different values with the "byte value" I think is not right and get it working that way) and I'm yet unsure of some of the formulas described above but they're mostly correct.

(For example I'm not sure whether this should be [C701 + X Movement...] or as described above: [North: C700 + X Movement of Connection Strip])

There aren't any major errors with the formulas though.

Last edited by Miksy91 (2012-05-28 15:31:29)

Offline

#18 2012-05-28 17:11:12

Tauwasser
Member
Registered: 2010-10-16
Post 280/452

Re: Map Connection Editing

Gee, seriously.

blockdata.png

I colored the map green, the border is brown, the block on the top is just for reference and logically before the start of map block data at 0xC700.

The equations were made for edge-of-map connections. You can connect maps inside of other maps, but it will have weird side-effects, because the game will change maps based on x and y changelines only. I once tried a map in map for Viridian Forest in Gold and happened to stumble upon this.

We'll go from simple north-bound connections increasing in complexity to east-bound connections:

North:  C700                                          | Start of block data
       +   3                                          | h-align to first block of map
       +   x_displacement_in_blocks                   | h-displacement
       ----------------------------------------------
        C703 + x_displacement_in_blocks

West:   C700
       +   3 * (w+6)                                  | v-align to first block of map
       +   y_displacement_in_blocks * (w+6)           | v-displacement
       ----------------------------------------------
        C700 + (w+6) * (y_displacement_in_blocks + 3)

South:  C700
       +   3                                          | h-align to first block of map
       +   3 * (w+6)                                  | v-align to first block of map
       +   (h - 1) * (w+6) + w                        | skip map
       +   3                                          | skip remaining border right of map
       +   3                                          | skip remaining border left of connection strip
       +   x_displacement_in_blocks                   | h-displacement
       ----------------------------------------------
        C700 + 3 * (w+6) + h * (w+6) + x_displacement_in_blocks
      = C703 + (h+3) * (w+6) + x_displacement_in_blocks


East:   C700
       +   3                                          | h-align to first block of map
       +   3 * (w+6)                                  | v-align to first block of map
       +   w                                          | skip first line of map
       +   y_displacement_in_blocks * (w+6)           | v-displacement
       ----------------------------------------------
        C700 + (w+3) + (w+6) * (y_displacement_in_blocks + 3)

      = C700 + (w+6) - 3 + (w+6) * (y_displacement_in_blocks + 3)
      = C6FD + (w+6) * (y_displacement_in_blocks + 4)

       In other words:

        C700
       -   3                                          | h-align to right side of map
       +   4 * (w+6)                                  | v-align to right side of map
       +   y_displacement_in_blocks * (w+6)           | v-displacement
       ----------------------------------------------
        C6FD + (w+6) * (y_displacement_in_blocks + 4)

So one thing we can notice is that Miksy defined the X_Movement differently for north and south connections, which should probably be rectified. The original equations in the tutorial F-Zero and I released do contain the proper formulas I just derived.

cYa,

Tauwasser

Last edited by Tauwasser (2015-02-11 20:58:50)

Offline

#19 2012-06-03 04:00:48

kanzure
Member
From: Austin, Texas
Registered: 2012-01-15
Post 10/19
Website

Re: Map Connection Editing

Tauwasser, you're probably right. At the moment, main.asm compiles (with the formulas I posted). Maybe you could edit it, and show me something better. Also, Sanky contributed installation instructions today, so everyone can follow along with how to compile the source code.

Offline

#20 2012-08-10 04:37:22

PixelEye
Member
From: Philippines
Registered: 2012-08-02
Post 27/162
Website

Re: Map Connection Editing

Miksy91 wrote:

I'm not sure if this is right but this is what I've written about them in my pc.

X Alignment = The left border where the connection begins in the connected map
X Movement of Connection Strip = The left border where the connection begins in the "starting map"


Easiest way of connecting two maps into each other would be so that both of them have the same x-size (up-down connection) or same y-size (left-right).
Then, you wouldn't have to mess around with "X Alignment" and "X movement of connection stip" values.
However, in other situations, you've just gotta figure out the right values.

Lol. This easier than i expected, all places in my rom, in Jhoto is much bigger now,the only thing i seem not to understand is the connection from Jhoto to Kanto, there are tiles that always pop out of nowhere.

Cheers.


LIKE US on Facebook!
---
Berries Inc.,Corp. Graphical Resource
---
I'M BACK, BUT MY WORKS BEEN ACCIDENTALLY DELETED ON MY PHONE(INCLUDING MY HACK THAT I'M DOING AND GEN 5 SPRITES AND TILESETS). SO THE SOLUTION WILL BE REVISING MY WORKS FROM 0 TO 456.

CHEERS.

Offline

#21 2013-01-28 06:00:46

comet
Member
Registered: 2012-04-09
Post 105/679

Re: Map Connection Editing

We've been talking about this a lot on IRC lately and decided the terms should be clarified:

"Current map position" or "OMDL" -> Strip position: The tile where the connection strip begins. Using Tauwasser's diagram, a conventional connection would land at the top-left corner of the w*3 and h*3 blocks. RAM

"Window" or "CMPDL" -> Map position: The x/y-alignment is for collision. The map position has the same purpose, but graphically. Basically, it's the tile where the map you just left starts, and the game draws the map you're coming into around it. RAM

"CSUBP" -> Strip pointer: The location of the first block used in the strip on the connected map. ROM

"Bigness" or "Height" -> Strip length: How tall or long the strip is. Bound by the extremities of the connected map.

Last edited by comet (2013-01-28 06:01:27)

Offline

#22 2013-01-28 12:59:05

FroggestSpirit
Member
Registered: 2012-03-12
Post 68/300
Website

Re: Map Connection Editing

What really helped me, is that I went to the map with an error, and I did a ram dump of xC700-xCAFF (thats the range for map data).
I hex'd the dump into freespace of gold, and loaded it in johtomap by adding 6 to the original width and height (3 blocks for each side, and the 3 is because when you stand in the middle of the screen, the max amount of blocks you can see above, below, and left/right of you is 3). This showed me the current map, and what the game had loaded for the connection strips. That's when it really clicked for me, and I understood it all.
http://i.imgur.com/ENf2pkm.png
There's an example, but keep in mind that the Bottom connection was WRONG.
Also... ignore the fact that there are a lot of rocks on the piers.

Last edited by FroggestSpirit (2013-01-28 13:00:22)


This isn't easy to say, but…
Music and ASM hacker

Offline

#23 2013-05-14 06:16:37

comet
Member
Registered: 2012-04-09
Post 243/679

Re: Map Connection Editing

comet wrote:

"Window" or "CMPDL" -> Map position: The x/y-alignment is for collision. The map position has the same purpose, but graphically. Basically, it's the tile where the map you just left starts, and the game draws the map you're coming into around it. RAM

When I said this I think I was testing using an east connection. The reality is this:

When you move in a map, the game keeps track of the block on the top-left of the screen. It uses that as a reference to draw new tiles at the edge of the screen that you're moving towards. This reference has to be updated when you enter a new map, since your position changes. To be clear, any horizontal (north/south) or vertical (east/west) distance between the player and the connection is added to this value at runtime.

This is probably old news for some people, but I was never corrected here.

In retrospect, window really is the best name for it too. I think for clarity it should be called the 'window block'.

Last edited by comet (2013-05-14 07:10:46)

Offline

#24 2013-07-01 02:53:06

hacker
Member
From: Batam Grove City
Registered: 2011-07-30
Post 493/548
Website

Re: Map Connection Editing

I got question, I make hiro begin in Mahogany, but when I start the game, the is freeze..
What happen with it?


[POKÉMON JOURNEY] hacking planning 2012
Visit my website  www.pokemonhackingblog.blogspot.com

Offline

#25 2013-10-27 23:51:44

Skurbert
Member
Registered: 2012-12-16
Post 59/95

Re: Map Connection Editing

There should be an easier way to do this. Kudos to you guys, who has the patience to deal with all of these numbers. You are the true heroes of this game. But for now on, we other can only stand aside and hope for better times, until there are easier methods of editing connections and size of the maps.

Still struggling about our goals.

Offline

Board footer

Powered by FluxBB