Super Mario Bros. 2:Enemy Data
The enemy data for an area is subdivided into what I call "chunks". Each chunk of enemy data corresponds to a page in the area. The first byte in a chunk holds the total number of bytes in the chunk (this total includes the first byte which holds the total). If the first byte is 01, then there's no other data in the chunk. Since enemies are always stored as two bytes, and since the chunk's byte count includes itself, the chunk byte count will always be an odd number.
To properly read in the enemy data, you need to know how many pages there are in the area. This information is stored in the area header. Each area has one more chunk of data than the number of pages. This last chunk always has a byte count of 01. It should never be anything else because it doesn't correspond to a page in the area; it kind of acts like and "end of area data" flag.
Enemies are stored using two bytes. The first byte is the YX coordinate byte defining the location of the enemy, and the second byte is the enemy type.
The XY byte is kind of weird. The best way to describe it is by an example. Say the XY byte for a particular enemy is 3B. The second half of the byte (B) is the number of tiles from the top that the enemy is situated. The first half of the byte (3) is the number of tiles from the left edge of the *current page* that the enemy is situated. The current page is dictated by the "chunk header" bytes in the enemy data section of an area. To determine what page the enemy is on, you have to know the entire sequence of enemy data up to and including that enemy.
The Enemy Type byte simply dictates what type of enemy it is.