summaryrefslogtreecommitdiff
path: root/GSC/connections.mdwn
blob: 0c76c2903616a815bbe07610e459518974987ccc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103

# definitions

*strip pointer* is the address of the first tile drawn from the blockdata of the new map that appears in a connection strip. Strips are always drawn starting from the top-left.

*strip destination* is the address of the first tile of the connection strip on the current map struct. The strip destination for a given connection will point to the location in the $c800 map to start drawing the connection strip.

*connection strip length* is the height of the strip in east/west connections, and the width of the strip in north/south connections. The opposite dimension is 3 blocks.

*window block* is the address of the block in the new map struct that is supposed to be at the top-left of the screen when you enter the new map. This is used as a reference to draw new tiles to the bg map. Vertical (east/west) and horizontal (north/south) distance from the edge of the map are factored in at runtime.

*x offset* and *y offset* adjust the player's position when entering the new map. This generally means placing the player at the opposite end of the map in the direction they entered from.

# diagram

<img src="/GSC/blockdata.png" />

(it's from <a href="https://sites.google.com/site/tauwasser/blockdata.png">tauwasser</a>)

# blockdata addresses

Here's a handy cheat sheet for common addresses used when making connections. Note that there is a 3 block border around the current map at all times.

* top left block of top left 3x3 is $c800
* top left block of top 3xw is $c800 + 3
* top left block of top right 3x3 is $c800 + 3 + w
* middle left block of top left 3x3 is $c800 + 3 + w + 3
* middle left block of top 3xw is $c800 + 3 + w + 3 + 3
* middle left block of top right 3x3 is $c800 + 3 + w + 3 + 3 + w
* bottom left block of top left 3x3 is $c800 + 3 + w + 3 + 3 + w + 3
* bottom left block of top 3xw is $c800 + 3 + w + 3 + 3 + w + 3 + 3
* bottom left block of top right 3x3 is $c800 + 3 + w + 3 + 3 + w + 3 + 3 + w
* top left block of left hx3 is $c800 + 3 + w + 3 + 3 + w + 3 + 3 + w + 3

<table>
<tr><td><b>block location</b></td><td><b>full expression</b></td><td><b>simplified</b></td></tr>
<tr><td>top left block of top left 3x3</td><td>$c800</td><td>$c800</td></tr>
<tr><td>top left block of top 3xw</td><td>$c800 + 3</td><td>$c800 + 3</td></tr>
<tr><td>top left block of top right 3x3</td><td>$c800 + 3 + w</td><td>$c800 + w + 3</td></tr>
<tr><td>middle-row leftmost-column block of top left 3x3</td><td>$c800 + 3 + w + 3</td><td>$c800 + w + 6</td></tr>
<tr><td>middle-row leftmost-column block of top 3xw</td><td>$c800 + 3 + w + 3 + 3</td><td>$c800 + w + 9</td></tr>
<tr><td>middle-row leftmost-column block of top right 3x3</td><td>$c800 + 3 + w + 3 + 3 + w</td><td>$c800 + (w * 2) + 9</td></tr>
<tr><td>bottom left block of top left 3x3</td><td>$c800 + 3 + w + 3 + 3 + w + 3</td><td>$c800 + (w * 2) + 12</td></tr>
<tr><td>bottom left block of top 3xw</td><td>$c800 + 3 + w + 3 + 3 + w + 3 + 3</td><td>$c800 + (w * 2) + 15</td></tr>
<tr><td>bottom left block of top right 3x3</td><td>$c800 + 3 + w + 3 + 3 + w + 3 + 3 + w</td><td>$c800 + (w * 3) + 15</td></tr>
<tr><td>top left block of left hx3</td><td>$c800 + 3 + w + 3 + 3 + w + 3 + 3 + w + 3</td><td>$c800 + (w * 3) + 18</td></tr>

<tr><td>top left block of hxw (current map)</td><td>$c800 + 3 + w + 3 + 3 + w + 3 + 3 + w + 3 + 3</td><td>$c800 + (w * 3) + 21</td></tr>
<tr><td>top left block of right hx3</td><td>$c800 + 3 + w + 3 + 3 + w + 3 + 3 + w + 3 + 3 + w</td><td>$c800 + (w * 4) + 21</td></tr>
<tr><td>bottom left block of left hx3</td><td>...</td><td>$c800 + (w * 3) + (w * (h - 1)) + (2 * (h * 3)) + 15</td></tr>

<tr><td>bottom left of bottom left 3x3</td><td>$c800 + (2 * (3 * w)) + (2 * (3 * h)) + (w * h) + 36 - 3 - w - 3</td><td>...</td></tr>
<tr><td>bottom left of bottom 3xw</td><td>$c800 + (2 * (3 * w)) + (2 * (3 * h)) + (w * h) + 36 - 3 - w</td><td>...</td></tr>
<tr><td>bottom left of bottom right 3x3</td><td>...</td><td>$c800 + (2 * (3 * w)) + (2 * (3 * h)) + (w * h) + 36 - 3</td></tr>
<tr><td>bottom right block</td><td>...</td><td>$c800 + (2 * (3 * w)) + (2 * (3 * h)) + (w * h) + 36 - 1</td></tr>
</table>

<div id="20x20" />
# 20x20 map simplifications

Flush 20x20 maps can be connected to achieve a seamless overworld.
Take caution to make applicable corners use the same blocks as the opposite diagonal map's border tile.

## North
    ; NORTH to Example
    db GROUP_EXAMPLE, MAP_EXAMPLE
    dw Example_BlockData + EXAMPLE_WIDTH * (EXAMPLE_HEIGHT - 3) ; strip pointer
    dw OverworldMap + 3 ; strip destination
    db EXAMPLE_WIDTH ; strip length
    db EXAMPLE_WIDTH ; connected map width
    db EXAMPLE_HEIGHT * 2 - 1, 0 ; y, x offset
    dw OverworldMap + (EXAMPLE_WIDTH + 6) * (EXAMPLE_HEIGHT) + 1 ; window

## South
    ; SOUTH to Example
    db GROUP_EXAMPLE, MAP_EXAMPLE
    dw Example_BlockData ; strip destination
    dw OverworldMap + (EXAMPLE_WIDTH + 6) * (EXAMPLE_HEIGHT + 3) + 3 ; strip location
    db EXAMPLE_WIDTH ; strip length
    db EXAMPLE_WIDTH ; connected map width
    db 0, 0 ; y, x offset
    dw OverworldMap + EXAMPLE_WIDTH + 6 + 1 ; window

## West
    ; WEST to Example
    db GROUP_EXAMPLE, MAP_EXAMPLE
    dw Example_BlockData + EXAMPLE_WIDTH - 3 ; strip pointer
    dw OverworldMap + (EXAMPLE_WIDTH + 6) * 3 ; strip destination
    db EXAMPLE_HEIGHT ; strip length
    db EXAMPLE_WIDTH ; connected map width
    db 0, EXAMPLE_WIDTH * 2 - 1 ; y, x offset
    dw OverworldMap + EXAMPLE_WIDTH * 2 + 6 ; window

## East
    ; EAST to Example
    db GROUP_EXAMPLE, MAP_EXAMPLE
    dw Example_BlockData ; strip pointer
    dw OverworldMap + (EXAMPLE_WIDTH + 6) * 4 - 3 ; strip destination
    db EXAMPLE_HEIGHT ; strip length
    db EXAMPLE_WIDTH ; connected map width
    db 0, 0 ; y, x offset
    dw OverworldMap + EXAMPLE_WIDTH + 6 + 1