Welcome to Data Crystal's new home! Data Crystal is now part of the TCRF family (sort of).
The wiki has recently moved; please report any issues in Discord. Pardon the dust.

Pokémon Red and Blue/Notes

From Data Crystal
< Pokémon Red and Blue
Revision as of 10:47, 17 July 2008 by 217.23.233.247 (talk) (New page: <pre> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% RGBY Map Headers & Stuff That Goes With It By Hat (a.k.a. The Black Phantom) Version 1.0 ...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    RGBY Map Headers & Stuff That Goes With It
    By Hat (a.k.a. The Black Phantom)
    Version 1.0
    -Feel free to distribute this document and/or edit it,
    -try and credit people you get info from and/or write how you updated...

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Main Credits (Structure Information):
-------------------------------------
  [Xeon]
    Wrote some stuff about Map Headers and Object Data.
    Which this document expands upon, a bit.

  [F-Zero] & [Tauwasser]
    Wrote a document (in German) explaining how GSC connection data is stored.
    RGBY connection data is stored almost the same way, it turns out, so
    that helped a great deal. All that is really different is the values you
    add the amount of blocks to.
...............................................................................


===============================================================================

    General Map Header Structure

===============================================================================

Explanation:
~~~~~~~~~~~~
This contains all the data (pointers count as data) to build the map.

Format:
~~~~~~~
  #1: [Tileset Number]
  #2: [(Y Size) Map Height]
  #3: [(X Size) Map Width]
#4-5: [*2 Bytes*: Pointer to Map]
#6-7: [*2 Bytes*: Pointer to Maps Text Pointers]
#8-9: [*2 Bytes*: Pointer to Maps "Script"]
 #10: [Connection Byte:
        00 = No Connections
        01 = North
        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]
   ?: [*11 Bytes per Connection*, No connections? Straight to "Object Data"!]
Last: [*2 Bytes*: Pointer to Object Data]

===============================================================================
    1) Tileset Numbers
===============================================================================

These are copied from a PDF by Cartmic, called "Pokemon Red Documents".

  00 = "Outside"
  01 = "Ash's House"
  02 = "Pokemon Center"
  03 = "Viridian Forest"
  04 = "Ash's House -- Again"
  05 = "Gym"
  06 = "Pokemon Center -- Again"
  07 = "Gym -- Again"
  08 = "House"
  09 = "Museum"
  0A = "Museum -- Again"
  0B = "Underground Path"
  0C = "Museum -- Again #2"
  0D = "S.S. Anne"
  0E = "Vermilion Port"
  0F = "Pokemon Cemetary"
  10 = "Silph Co."
  11 = "Cave"
  12 = "Celadon Mart"
  13 = "Game Freak HQ"
  14 = "Lab"
  15 = "Bike Shop/Cable Center"
  16 = "Cinnabar Mansion/Power Plant etc"
  17 = "Indigo Plateau"
  18 = ???

===============================================================================
    2 & 3) Map Height (Y) & Width (X)
===============================================================================

Exactly that, the amount of blocks high and wide the map data is.

===============================================================================
    4 & 5) Map Data Pointer
===============================================================================

You can use Pokemap/GoldMap for hacking all this quite easily.

The map you walk around on and stuff is stored as block indexes.
A single block consists of 4*4 tiles, so... somewhere else (the Block Data),
the block is stored as 16 bytes...

...the same amount of bytes as a 2bpp tile.
Read stuff on Romhacking.net for information on bits per plane/pixel (bpp).

===============================================================================
    6 & 7) Pointer to Maps Text Pointers
===============================================================================

2 byte pointers to text that is used on that map.

===============================================================================
    8 & 9) Pointer to Maps "Script"
===============================================================================

Not entirely sure what/when/where/why/how.
But it contains unique things to the map at a guess, as I've found such things
as "what Pokemon is inside a Pokeball on the desk data"(Eevee) living there.

===============================================================================
    10) Connection Byte
===============================================================================

 Note:
 ~~~~~
 I think I wrote the directions in the order connection data is stored...?
 By the way if this value is 00h it is immediately followed by the Object Data
 Pointer, no gap. Repeated list...

 Connection Byte:
    00 = No Connections
    01 = North
    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

===============================================================================
    ?) Connection Data (0-44 bytes, explained in more depth: further down)
===============================================================================

===============================================================================
    Last) Object Data Pointer
===============================================================================

The last thing in the Map Header. It points to a bunch of certain stuff that
is stored in certain structures, because they are so overly used on maps.

Object Data is discussed at the end of this document.
...............................................................................


===============================================================================

    *** Hacking Connections ***
    This might take a bit of "practise hacking" to fully understand what the
    hell is being said here.

===============================================================================

Explanation:
~~~~~~~~~~~~
The "Connection Byte" determines how many connections are in this space,
including none at all.

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

Connection Strip Example:
-------------------------
Connection Byte 0D...
the C rectangles are the connection strips for the current map...

                &&&      \
                & &      |
                & &      |
                & &      |
                & &      |
                & &      |- Connected Map (North)
                & &      |
   +++++++++++++CCC+++++ |
   +++++++++++++CCC+++++ |
   +++++++++++++CCC+++++ /
   +++###############+++
   +++#             #+++<------------- '+'s = current maps border
   +++#             #+++
   +++#   Current   #CCC&&&&&&&&&&&& 
   +++#             #CCC           &
   +++#     Map     #CCC           &
   +++#             #CCC           &
   +++#             #CCC&&&&&&&&&&&&
   +++#             #+++
   +++###############+++
 / +++CCCCCCCCCCCCCCC+++
 | +++CCCCCCCCCCCCCCC+++
 | +++CCCCCCCCCCCCCCC+++
 |    &             &\_____________/
 |    &             &            \
 |    &             &            Connected Map (East)
/|    &             &
|\    &&&&&&&&&&&&&&&
|
\_ Connected Map (South)



===============================================================================
    #1 : Map Indexes
===============================================================================

Not included! Download UltraMap, the text file known as "RedEnglish.txt"
contains all the Map Indexes in decimal, which you'll obviously need to convert
to hex.

===============================================================================
 #2-#3 : "Connection Strip" Location
===============================================================================

The "connection strip" pointer -- points to the area of the connected map that
is visible when standing before you even enter it. Points to the upperleft
block of the "connection strip".
      * connection strip is always 3 blocks wide (E/W connection)
                                   3 blocks high (N/S connection)

===============================================================================
 #4-#5 : Current Map Position
===============================================================================

This points to the part of the current map (in RAM somwhere or something)
that the connection strips upperleft block is placed on the current map.

____________________
Connection |
Direction  | Formula
___________|_______

     North: C6EB + X_Movement_of_Connection Strip

     South: C6EB + (Height of Map + 3) * (Width of Map + 6) +
                   X_Movement_of_Connection Strip

      West: C6E8 + (Width of Map + 6) * (Y_Movement_of_"Connection Strip" + 3)

      East: C6E5 + (Width of Map + 6) * (Y_Movement_of_"Connection Strip" + 4)

===============================================================================
    #6 : Map "Bigness"
===============================================================================

North/South Connection = Connected Maps Width
East/West Connection = Connected Maps Height

===============================================================================
    #7 : Map Width
===============================================================================

The width of the connected map.

===============================================================================
    #8 : Y alignment
===============================================================================

Relative Y-position of player after entering connected map.

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

===============================================================================
    #9 : 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

===============================================================================
#10-#11 : X alignment
===============================================================================

Position of the upper left block after entering the Map.

____________________
Connection |
Direction  | Formula
___________|_______
     Above: C6E9h + Height_of_connected_map * (Width_of_connected_map + 6)
South/East: C6EFh + Width_of_connected_map
      West: C6EEh + 2 * Width_of_connected_map
...............................................................................


===============================================================================

    Object Data: General Structure

===============================================================================

Object Data
===========
[Maps Border Tile]
[Number of Warps][Warp Data]
[Number of Signs][Sign Data]
[Number of People/Trainers/Items]
[People Data]
[Trainer Data]
[Item Data]
[Warp-To Data]

Warps:
------
[Y position][X position][Warp-To Point][Warp-To Map]

Signposts:
----------
[Y position][X position][Text String Number]

Normal People:
--------------
[Picture Number][Y position + 4][X position + 4]
[Movement 1][Movement 2][Text String Number]

Trainers:
---------
[Picture Number][Y position + 4][X position + 4]
[Movement 1][Movement 2][Text String Number]
[Trainer Type][Pokemon Set]

Items:
---------------------
[Picture Number][Y position + 4][X position + 4]
[Movement 1][Movement 2][Text String Number]
[Item Number]

Warp-To Points
--------------
[*2 Bytes*: Event Displacement???][Y position][X position]

Event Displacement Formula:
~~~~~~~~~~~~~~~~~~~~~~~~~~~
C6E3 +  ((Map width + 8) * (rows above + 1))  + (X movement + 4)
Just set it to C6E3 if you're not using it I think.

############################################################### THE END FOR NOW