Back in what must've been the mid-80s, when every microcomputer included BASIC and Choose Your Own Adventure Books were really popular, there were some novels that had BASIC programs listed in the text, for you to type in and further enjoy.
For example, as I recall, in one of these books, the adventurers were infiltrating an undersea base (and eventually wiped the bad guy's data storage [I do believe it was a hard drive, even though they were uncommon then]). One of the programs involved a game were you piloted a submarine and had to avoid or shoot sharks. The code was in BASIC; minor changes (such as 'CLS' -> 'HOME') had to be made for your specific computer, and it used good old 40-column text-mode to display the action. IIRC, the plot never depended upon the programs.
My question is, does anyone else recall these sorts of books? Do you know any titles that I could look for, or of any online? I am toying with the idea of writing a story like this (no, not in BASIC!), and would really like to see how it was done, back in the day.