Copyright and Trademarks are two very different things. Copyright is granted to original works of specific types, or compilations. So like, recipes for example, are not covered by copyright, but cookbooks are. Titles are also not covered by copyright, so you might find ten completely different songs called “Love Story”.
Trademarks, however, must be registered. TARDIS, for example, is probably covered by a trademark.
Now as pertaining to the example of the badly remembered song lyrics, things that are substantially modified are considered fair use under copyright law, so that excerpt is probably safe. In addition, copyright law provides a great deal of leeway to use in the form of parody, and it’s quite obvious that the lyrics transformed here qualify as parody.
If you explicitly used word for word lyrics, it would probably be ideal to credit the songwriter or whoever owns the copyright to that song.
If someone was to use copyrighted or trademarked content in a game, it probably would be relatively safe as long as the game was not entered in a competition or used to make money, unless the author had the express permission of the copyright owner. Of course in the example of fan fiction (of which there are also many examples of fan interactive fiction) the author simply has to hope they won’t be pursued by lawyers.
This leads us to software copyrights. Technically, any game we write contains code copyright to the author of the game system. If we include any extensions, we’re including code copyright by the extension authors. It’s assumed, I suppose, that extension authors aren’t interested in pursuing the authors of games who use them.
Now, there are games where people have added grey area content to their games, such as say, “public domain” clip art images or media files. I must confess that I myself once included a MIDI file of unknown origin in a game for a sound effect. It could be argued that this grey area is covered by the “transformative use” portion of copyright law.
Transformative use is best argued in the form of parody, but can also be covered by criticism or analyzing. Now, if a text adventure was considered a parody of real life, you could probably throw any copyrighted material in it you want as long as you were satirizing the original content. You’d be surprised how far that law goes in sheltering the author of the infringing work if it’s a parody.
But you would have to be substantially transforming the original work, I suppose. If the original was song lyrics and you transformed them while making it funny, you can count on copyright law protecting you.