This article will try to describe how levels work in the pmd2 games.
There are essentially 2 modes that the game can run levels as. In-dungeon, referred to as simply "Dungeon", and out-of-dungeon, referred to as "Ground". Ground mode is the default mode. Dungeon mode is triggered from scripts run by the Ground engine.
- Dungeon: The dungeon mode is run as soon as a script from the "ground" engine calls the command to run a dungeon. And once a dungeon concludes, execution returns to the line after the command to run the dungeon, and the game falls back into "ground" mode. Scripts aren't executed at all during dungeon mode, since the overlay running scripts is unloaded and replaced with the dungeon engine overlay.
- Ground: The game runs in this mode as soon as the chunsoft logo pops up on screen. Game scripts are executed only in this mode.
The Level Table
Located in the ARM9 binary. (arm9.bin) Its a table associating a level ID to level related data. Every "Ground" levels in the game have an entry in this table.
Location in the Binaries
The table is always inside the arm9 binary, and never in an overlay.
|Game||Game Code||Table Offset||Nb Entries|
|North American Explorers of Sky||C2SE||0xA5488||431|
|European Explorers of Sky||C2SP||0xA5BE0||459|
|Japanese Explorers of Sky||C2SJ||0xA689C||436|
Each entry is 12 bytes and is laid out this way.
|0x00||2||int16||mapty||Type of the map. A value from 0 to 11 defining how a map is loaded and displayed.|
|0x02||2||int16||unk2||Unknown value. (0 to 306)|
|0x04||2||int16||mapid||ID number of the map. Most likely used in the bg_list.dat file to look up the level's resources files.|
|0x06||2||int16||unk4||Unknown value. (-1 to 7)|
|0x08||4||uint32||ptrstring||Pointer to a null terminated string, containing the internal name of the level. Is used as directory name for the script to run, and for debugging.|
Level Constants and Map Types
Depending on the map type, and on the command used to load a level, a different set of constant will be used by the game.
Edited by evandixon