Information about maps
#1
Greetings. I want to share information about maps. When a map is loaded, it also loads many things with it. It includes events, npcs, exits and chests. All of them are stored in different structures.

Headers

All mentioned structures have in common a header and their related data. The header structure is probably #$0340 bytes with 416 entries for each map, except the last one, with two bytes by entry. After the header structure, it follows the data structure. They are two different structures. However, in the game code, they are referenced from the header initial address (base). As example, LDA $DFBB00,X can load the first byte of the header structure (2 bytes index) or the first byte of the entrance structure (6 bytes of data). It is necessary to pay attention in the index to determinate the kind of structure which are being loaded. In this case, header structure if X < #$0340 or the entrance structure if X > #$0340.

The header structure is only two bytes for each map. They are actually indexes to search for the data structure. To calculate the header index for a specific map, the function is: header index = (map number * 2) + header base.

As example, the header base for the entrances are $DFBB00. For the map #$0074 (House of Gau's father, indoors), the index for the entrance structure is:
Code:
header index = (map number * 2) + header base
        header index = (#$0074 * 2) + #$DFBB00
        header index = (#$E8) + #$DFBB00
        header index = #$DFBBE8

To calculate the data address: data address = value stored in header index + header base. It is the start of the data structure for the specified map.

The game system checks the difference between the header index and the next header index. The referenced structures have a fixed size but multiple instances of the structure can be stored. As example, the structure size of entrances are six bytes. If the difference is 0, there are no exists for this map. If the difference is 6, there are one exit in this map. If the difference is 12, there are 2 exits in this map. If the difference is 18, there are 3 exits in this map, etc.

C4/0000 Events

Code:
Events header:  C4/0000

00      position x
01      position y
02      event pointer: low
03      event pointer: middle
04      event pointer: high

When the characters steps in the (x,y) position of the map, the designed event is executed.

If the event doesn't move the character or have a conditional branch to null itself after its execution, it will be called repeatedly in a infinite loop.

C4/1A10 Npcs

Code:
NPCs header:    C4/1A10

00      event: low
01      event: middle
02 #$01 event: high
   #$02 event: high
   #$04 palette
   #$08 palette
   #$10 palette
   #$20 intangible
   #$40 ???
   #$80 presence
03      ? id
04      x position
05      y position
06      graphic set
07 #$01 movement type
   #$02 movement type
   #$04 movement type  
   #$08 movement type
   #$10 map layer
   #$20 map layer
   #$40 vehicle
   #$80 vehicle
08 #$01 direction facing
   #$02 direction facing
   #$04 don't turn npc if spoken
   #$08 ???
   #$10 ???
   #$20 ???
   #$40 ? can fix "sliced" graphics?
   #$80 ???

Sets the initial data for the NPCs when a map is loaded.

For the movement type, i only found #$00 (static) or #$03 (movement) as valid values. All other values sets the npc as static or have weird behavior.

DF/BB00 Exits

Code:
Exits header:   DF/BB00

00      x position: old
01      y position: old
02      map id: low
03 #$01 map id: high
   #$02 ???
   #$04 ???
   #$08 display location name        
   #$10 direction facing
   #$20 direction facing
   #$40 ???
   #$80 ???
04      x position: new
05      y position: new

When the character steps in the (x,y) position, warp it for the designed map with the designed coordinates.

It is imperative to have valid coordinates for the setup. If the character can't access the map position, the setup is useless. If the new map position isn't walk able, the character is permanently stuck. If the new map position bypass the map size, the coordinate system is corrupted and all exits are disabled or aren't functional.

ED/82F4 Chests

Code:
Chests header:  ED/82F4

00      x position
01      y position
02      chest id
03      chest type
04      chest content

Sets the chest for the map. Actually, if the character press the A button in front of the designed position, the chest event is executed. If the tile in the position is a chest, the tile changes as a opened chest. Otherwise, the tile isn't changed.

Unlike the other headers, the index of the data structure is relative to $ED/8634 instead of $ED/82F4, the actual header base.

Others?

There are other settings for the map, like the background in battles, the song played, enemy formations used, etc. I don't know where this setup is stored, but i suspect of the $ED/8F00 structure. The structure size is #$021 and doesn't have a header structure.

I don't have enough information about this structure but i will let you know i consider it a good suspect for the low level setting of the maps.
Reply


Messages In This Thread
Information about maps - by HatZen08 - 09-10-2015, 11:14 AM
RE: Information about maps - by Tenkarider - 09-11-2015, 09:48 AM
RE: Information about maps - by HatZen08 - 09-11-2015, 02:56 PM
RE: Information about maps - by abyssonym - 09-11-2015, 03:25 PM
RE: Information about maps - by HatZen08 - 09-12-2015, 03:47 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Seeking X-Zone information Fenrir 8 7,795 06-22-2017, 02:11 PM
Last Post: Gi Nattak
  Running in world maps Tenkarider 1 2,327 12-27-2015, 09:56 AM
Last Post: madsiur
  Still Stuck on Tile Information sleepydude 9 8,626 12-18-2015, 07:08 PM
Last Post: Tenkarider
  Portrait Palette Information Catone 5 5,482 12-11-2015, 07:16 AM
Last Post: Catone
  Messing with maps... Tenkarider 11 10,609 07-13-2015, 07:44 PM
Last Post: Lockirby2
  Need some assistance with my hack, maps, events, graphics JCE3000GT 24 21,343 03-05-2014, 04:04 AM
Last Post: JCE3000GT
  Duplicate maps B-Run 4 5,693 06-10-2013, 09:32 PM
Last Post: Ghost XIII

Forum Jump:


Users browsing this thread: 1 Guest(s)