Wouldn't it be possible to release the code without the game data, together with a program which would extract the data from game files provided by the user to build a cartridge image ? That way, people who own a copy of Doom 2 could legally play it, while others could play the levels from the freely available demo. DOOM (and other games) ports on other machines use this strategy, and I don't think there are legal problems in this case.