Actually, once I got to work on the level insertion program, I realized that an estimate of the number of rooms wasn't neccessary. The game engine doesn't have the number of rooms hardcoded, it simply follows the pointers. Therefore, my code simply produces as many rooms as needed and will set up the pointers as required. But, thanks for the information.
As for room numbering conflicts, I'm aware of the problem and have a solution. My current code renumbers the rooms. This is to avoid conflicts and also make the segregation by type simple. Currently, I'm almost done with a stripped down proof of concept version.
It doesn't currently handle pipe connections, but I have a pretty good idea how I'll handle that as well. Basically, it'll go through the area data and record the pipe connections. Then, after the renumbering, it'll go through the list of pipe connections and patch them up.
A bigger issue is the fact that we can only have a max of 32 rooms of a given type as room numbers are stored as five bits (plus two bits for type). If we need more than that, we'll have to come up with an ASM hack of some sort. As one bit of the room numering bytes is unused, I could expand the max to 64 per type. However, as pipe pointers only have 7 bits for room, that won't work for them. The solution in that case would be to ensure that all rooms pointed at by pipe pointers are numbered less than 32.
Anyway, I'm going back to coding.
Well, I've got the proof of concept level inserter working. At least it seems to be working. You can't do a whole lot of testing without pipes, but level 1-1, the pipe intro, and the first room of level 1-2 seem to be working anyway. Now I guess I'll have to start work on the pipe pointer functions.