Tutorial: Secondary Mapheader including Connections
Version 1.31
(C) 2002 by [Tauwasser] & [F-Zero (
devzerox@gmx.de)]
Post into the forums for any informations and questions or just PN or EMail us.
Introducion
There are 2 kinds of Mapheaders:
1.: The real Mapheader (aka "primary Mapheader")
2.: The Mapdataheader (aka "secondary Mapheader" or Blockheader)
The primary Mapheader contains all Data being part of a Map:
Music, Time, Worldmap-Byte and Tileset-Index.
The secondary Mapheader contains in contrast to the first only that Information a rom needs to build a Map:
Height&Width, Borderblock, Mapdatapointer and Connections and Script- & Eventpointer.
This tutorial only explains the secondary Mapheader.
Secondary Mapheader: (Public Part)
===============================================
[Borderblock][Height][Width][3-Byte Mapdatapointer]
[S/E-Bank][2-Byte Scriptpointer][2-Byte Eventpointer][Connection-Byte]
===============================================
Borderblock = Block displayed beside the Map (resp. out of the real Map)
Height = Count of vertical blocks on a Map
Width = Count of horizontal blocks on a Map
Mapdatapointer = Points to the Mapdata
S/E-Bank = Both, Bank of Scriptheader and Events
Scriptpointer = Points to the Scriptheader
Eventpointer = Points to the Events
Connections:
Specifies if and where connections are placed.
Only last 4 Bits are used and they are used like that:
&8 (Bit 3): [-Above]
&4 (Bit 2): [-Below]
&2 (Bit 1): [-left]
&1 (Bit 0): [-right]
1 = Connection in the specified direction exists
0 = Connection in the specified direction doesn't exist
Warning: Bits are counted backwards.
-----------------------------------------------------
Example:
07 is: 0 0 0 0 0 1 1 1
BIt 7--/ | | | | | | | = 0
BIt 6----/ | | | | | | = 0
BIt 5------/ | | | | | = 0
BIt 4--------/ | | | | = 0
BIt 3----------/ | | | = 0
BIt 2------------/ | | = 1 = Below
BIt 1--------------/ | = 1 = Left
BIt 0----------------/ = 1 = Right
Meaning: Connections to below, right and left of the Map.
-----------------------------------------------------
All existing Connections are listet after the Connection-Byte of the secondary Mapheader.
Not existing Connections don't count. So there is no 'Data-Hole' in the Data.
Connection-Header:
(Original from Tauwasser. Retesting and formulas from F-Zero)
===============================================
[Map bank][Map-Nr.][2-Byte connection strip pointer][2-Byte connection strip destination]
[bigness][Width][Y-Eventline][X-Eventline][2-Byte window]
===============================================
Map bank = Map bank of the connected Map
Map-Nr. = Number of the connected Map in the Map bank
connection strip = Part from the connected Map that is viewable of the connected Map
connection strip pointer:
Points to the upper left block of the connection strip.
(The bank the Blockdata is in, is loaded out of the Mapheader of the connected Map.)
The connection strip is always 3 Blocks high resp. wide
(depending on the connection's direction)
Downwards more information on width & height of connection strip.
connection strip destination:
At that position the connection strip is located at the Map. It is calculated like this:
Connections' direction|Formula
Above: C703h + X_movement_of_the_connection_strip_in_blocks
Below: C703h + (Height_of_the_current_Map + 3) *
(Width_of_the_current_Map + 6) + X_movement_of_the_connection_strip_in_blocks
Left: C700h + (Width_of_the_current_Map + 6) * (Y_movement_of_the_connection_strip_in_blocks + 3)
Right: C6FDh + (Width_of_the_current_Map + 6) * (Y_movement_of_the_connection_strip_in_blocks + 4)
The first 2 values of the 4-value result are exchanged with the last 2 values. (Standard 16-Bit Exchange)
Bigness:
Bigness of the connection strip in blocks.
In case of a connection
Above/Below the Map: Width of the connection strip.
in the Left/Right the Map: Height of the connection strip.
Width = Width of connected map in blocks
Y-Eventline:
Relative Y-Position of HIRO after Map change.
Connection's direction|Formula
Above: (Heigt_of_connected_map * 2) - 1
Below: 0
Left/Right: (Y_movement_of_connection_strip_in_blocks * -2)
X-Eventline:
Relative X-Position of HIRO after Map change
Connection's direction|Formula
Left: (Width_of_connected_map * 2) - 1
Right: 0
Above/Below: (X_movement_of_connection_strip_in_blocks * -2)
Window:
Position of the upper left block after entering the Map.
Connection's direction|Formula
Above: C701h + Height_of_connected_map * (Width_of_connected_map + 6)
Links: C706h + 2 * Width_of_connected_map
Unten/Rechts: C707h + Width_of_connected_map
===============================================
At the end a sketch to verify some used phrases:
---/¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯\\¯¯¯ Width_of_current_map_in_blocks
+++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++
+++XXXXXXXXXXXXXXXXXXXXXXXXX+++¯\\
+++XXXXXXXXXXXXXXXXXXXXXXXXX+++ |
+++XXXXXXXX/¯¯¯¯¯¯¯\\XXXXXXXXX+++ |
+++XXXXXXXX| Map No1|XXXXXXXXX+++ +- Height_of_current_map_in_blocks
+++XXXXXXXX\\_______/XXXXXXXXX+++ |
+++XXXXXXXXXXXXXX|============|==|= Width_of_connection_strip_in_blocks
+++XXXXXXXXXXXXXX| XXXXXXXXXX+++_/
++++++++++++++++ZZZZZZZZZZZZZZZ########¯\\
++++++++++++++++ZZ connect stripZZ######## |
++++++++++++++++ZZZZZZZZZZZZZZZ######## |
---|--------------------|#################### |
---|--------------------|#####/¯¯¯¯¯¯¯\\######## |
---|--------------------|#####| Map No2|######## +- Height_of_connected_map_in_blocks
---|--------------------|#####\\_______/######## |
---|--------------------|#################### |
---|--------------------|#################### |
---|--------------------|#################### |
---|--------------------|####################_/
---|--------------------|\\_______________________/___ Width_of_connected_map_in_blocks
---|--------------------|
---\\_______________/_ X_movement_of_connected_map_in_blocks
Every X resp. # represents a block of a Map.
The + -Characters represent the Map's border.
The connection strip is represented by Z.
The -lines don't represent nothing.
The following example is founded on the sketch above.
First we'll read the values out: (decimal)
Width_of_current_Map = 25
Height_of_current_Map = 7
Width_of_connected_Map = 23
Width_of_connected_Map = 11
X_movement_of_connection_strip_in_blocks = 13
Bigness_of_connection_strip_in_blocks = 15
Y_movement_of_connection_strip_in_blocks doesn't exist.
That values can be put in the given formulas.
So. That's all.