AD 0D 10 22 75 BF ...
Megami Tensei II — ROM Notes
Source: Digital Devil Story Megami Tensei II Messiah Project 2036
Last updated: 2023-04-29
Here's a bunch of notes about the code structure of Digital Devil Story: Megami Tensei II, derived from modifying the Kyuuyaku version of the ROM. These notes have been cleaned up compared to my messy and often wrong original notes, but I've preserved every bit of correct information I've found in some form. There will be a few notes about the Famicom version of the game as well, even though I didn't do much with it.
There are several skills that are enemy-only in the game, and most of them work if given to the player via a demon that has them.
Bufu and Mudodyne are two spells that only Evil, enemy-only demons have, but they function perfectly for the player and even have their own animations that cannot be seen otherwise.
Some enemy-only attack skills, such as Poison Gas and Petra Eyes, can be used by the player. They have text strings in the code ("$NAME exhaled poisonous gas" and "$NAME glared sharply") that cannot be seen without obtaining these skills.
A few others, such as Deathtouch and Curse, do not have text strings that are compatible with player use (i.e. their only associated text strings are "The demon used a chilling touch", but not "$NAME used a chilling touch"), and as a result they do not seem to ever trigger for the player.
There are two types of critical hits in both versions of Megami Tensei II. There are regular critical hits and deathblows. In the Kyuuyaku version of the game, deathblows do not seem to trigger most of the time or at all, but they can be forced by using a cheat code.
Judging by the way that the cheat code functions, a deathblow most likely is meant to occur when the player rolls a critical hit, and then rolls a critical hit a second time.
This is the big change I was attempting to make: to allow the player to fuse and use Evil demons. There is code and data in multiple places that affects how fusion functions. The first piece I discovered is located at
0x1865A0 in the English version of Kyuuyaku Megami Tensei, and begins as follows:
Several more lines of assembly code follow. This section of the code appears to perform the math necessary to determine where to stop on the clan list (discussed below) based on the ingredient demons. This code is fairly sensitive, and modifying it can cause the game to read well past the clan list and interpret code as valid fusion data.
In particular, changing the address the game loads to the accumulator from (from
1000D to something else) can result in fusions that change each time you attempt to view their results — or simply crash the game. This is because the game stores component demons at that address.
A different section around
0x185E25 controls what demons are allowed as fusion materials. Certain operations in this region of code discard Evil demons as candidates for double fusion and Neutral and Evil demons as candidates for triple fusion. Though the player cannot normally obtain Evil demons, these checks appear to exclude demons of invalid alignment, rather than include demons of valid alignment.
In the Kyuuyaku Megami Tensei version of the game, fusion results are determined by iterating through a table that begins as follows and making comparisons to the mathematical results generated in "fusion math," above:
01 02 0C 18 24 2F 38 42 4F 5B 5E ...
This table is an ascending list of bytes that correspond to the IDs of the highest-level demon in each clan; for example,
4F is Jaki Azazel, the highest-level Jaki, while
01 is the true final boss, who is obviously the only member of his clan.
This list exists in both the Famicom and Super Famicom versions of the game, in multiple places. In the Super Famicom version, the first instance of this list is used to distribute clans to the game's demons. In the Famicom version, the first instance of this list has a similar but reduced function. Where the two differ is how the second instance is used: in the Super Famicom version, it can be altered to change the results of fusion by clan, while in the Famicom version this does not work.
It is worth noting that this list must stay in roughly ascending order. Attempting to change the bytes
5B in a way that does not work with the fusion math above will cause the next step to fail — in this example, the only possible result will be Jaki Azazel, no matter how low level the components are.
Once the game determines what clan the result should be in, it checks to see if the level of that demon (for example, Jaki Azazel) is at or below the average of the two components' levels. If it is not, the game checks the next highest level demon in the clan, and so on and so forth, until it reaches a demon that is an appropriate level.
Demon skills and statistics
The statistics of each demon are stored in a very short format, with most demons being crowded together in the same block of ROM.
For example, these are Garm's statistics as represented in ROM:
12 09 06 0A 09 06 04 11 43 5B 62 76 0A 0F 00 00
The first byte is Garm's level, while the next six are its core statistics — Vitality, Intellect, Strength, Agility, and Luck, as well as its invisible Defense stat. It's not clear to me what the next two bytes are, but the the next three (
76) represent its skills, one byte each. Finally, the third-to-last byte may be the demon's resistance profile: there are roughly 30 different types of resistance a demon might have in Megami Tensei II.