UNCLE BERNIE'S CODEBREAKER GAME FOR APPLE-1
This is a fun little game that once was very popular in the 1970 in various forms. Objective of the game is to guess a secret code of the opponent. Most of its numerous variants and knockoffs appear to have been inspired by the commercial game "Mastermind" which used colored pegs on a small game board so you had to think in colors. On the early programmable calculators like the HP-67 and the TI-59 you had to guess a number, much like the "Bulls and Cows" game that predated "Mastermind" by maybe a century. When played with pencil and paper the secret code was preferably a four letter word, limited to the first few letters of the alphabet to make it playable.
The latter is the variant that was found in numerous incarnations in many computer magazines of the 1970s and 1980s as a type-in listing, mostly in BASIC, and ad nauseam. As if every BASIC beginner would have wanted to tackle this game to demonstrate their newly acquired programming "skills", and ruthless editors, wanting to fill the pages of their otherwise boring advertising rags, accepted and printed that crap, and I mean "crap", because none of these beginner grade programmers had ever figured out how the computer could guess a "secret code word" made up by the human player. It still eludes me how we could have cherished all these computer magazines so much, back in the day. I still have some, and if re-read now, they look bland and trivial to me. This even applies to the once famous BYTE magazine. I have all the issues from the beginning to December 1978. Bought recently, off Ebay, of course. When I was a teen I could not afford to buy them, and I had to go through the ordeal of a long tramway and then a subway ride to the city's main train station where there was an international book store which had them. There I would browse through the most recent BYTEs until I got shown the door. There were (and still are) a few gems in those early BYTE magazines, though, unlike most other such magazines of the time. Most magazines catering 8-bit computers died in and after the year 1988, and good riddance. BYTE morphed into a product review / advertising "telephone book thick" monstrosity targeting the PC crowd. Still, they had some gems from time to time. I remember their great in-depth articles on the first RISC CPUs --- all now gone and buried except the ubiquitous ARM. I wish I had those BYTEs in my collection.
WHY AND HOW I CODED THIS GAME In THE 1970s
Back in 1976, when the Apple-1 came out, which I did not know of, as I was a young teenager, I itched for a KIM-1. A classmate had one because his dad, a mainframe computer professional, had bought it out of his own curiosity. But my dad was busy designing rocket engines for a defense contractor so there was no way to talk him into buying me a KIM. And my pocket money and savings just had been depleted by building a digital clock of my "own" design (well, schematics taken from a book and modified for the TTLs I had desoldered from computer scrap - I only had to buy the type 7447 decoders, some 7490 counters, the crystal, and the 7-segment displays).
So I proceeded to design and build my own 8080 based computer with much the same functionality of a KIM-1. Having no money makes inventive minds ! The 8080 and the 2708 I got as a gift from an uncle of mine who designed telecom equipment - towards Fall 1976 they already were throwing out these obsolete three supply voltage parts from their lab drawers right into the scrap bin. But the 2114 RAMs, the 8224 clock generator, and the 7-segment displays I had to buy myself. The TTLs, again, were salvaged from computer scrap. So it became 1977 until my own 8080 based KIM-1 knockoff finally came to life. It was a weird design unlike anything ever seen in magazines. There was no 8228 system controller IC - too expensive - and due to lack of any 74138 decoder which never had appeared on any salvaged PCB the keyboard port register occupied the whole upper 32 kBytes of the 8080's address range. Hilarious ! There was no way to expand its memory. It was forever stuck at 1 kByte of RAM and 1 kByte of EPROM. My "reasoning" was that I could not afford to buy more 2114 ICs anyways. But still not bad for a teen designing his first computer. And like Woz, I learned from the experience and never made the same mistakes again. I think without the lessons learned from the disastrous Apple-1 his Apple-II would have been as terrible as most other flawed early 8-bit microcomputers you probably never heard of because they flopped and bankrupted their manufacturers. The Apple-II, however, was a sound design that was innovative and avoided all the shortcomings of the Apple-1. So it became a stellar success !
But back to my 8080 based contraption. Its 1 kByte machine language monitor even had a sort of "mini assembler" using labels as branch targets - I feature I had seen in the HP-67. And the first game I wrote for this machine was "Codebreaker". And yes, the player and the computer would take turns in guessing the secret code of the opponent. I had figured out an algorithm how the computer could do that with spooky efficiency. Little did I know that me, as a teen, may have matched, at least somewhat, the famous Donald Knuth with that feat. He analyzed the game in the same years, 1976 and 1977. But of course, him being a real scientist, his algorithm was far more sophisticated than the mine as he added a minmax search after the first steps needed to find a reasonable guess. So his algorithm always guesses in an optimum way. My algorithm does not do that. The human player would stand no chance if it were so, and quickly get fed up and toss the game into the digital trash can. I kept it simple and stupid even in this incarnation of the game for that reason. Any game should be fun for the human player, and not bring frustration.
REDISCOVERY OF MY OLD CODE
Just recently, when rummaging through my old notes trying to find the schematics of my 8080 computer, I found the core algorithm written by my younger self in 8080 assembly code almost half a century ago. So I decided to rewrite it in 6502 assembly language targeting the Apple-1. It is one of the few types games that is not hampered in any way by the Apple-1's incredibly slow and functionally limited video section:
While I was at it, I also experimented with some additional code which would make the same binary run on both the Apple-1 and the Apple-II, and on the latter, to faithfully emulate the look & feel of the Apple-1 as far as the screen output is concerned. But as none of my real Apple-II in my collection work anymore, I had to try it on a clone that was made in Taiwan in 1986, which still works without a flaw, after all these 35 years. So I don't know if my code works on any real Apple-II or not. If you have an Apple-II which works, please try it out and give me feedback ! And tell me which Apple-II you ran it with ! If I'm right with my observations I made while coding this game, which is the first program I ever wrote for the Apple-II, the Apple-II did inherit a lot of "genes" from the Apple-1 on the machine language monitor / machine language API level, far more than you would think. If I'm wrong, the game won't run. But it did work on the clone !
HOW TO DOWNLOAD AND USE THE GAME
You can find the game's manual pdf in the download section ("Attachments") below to if probe you may like it. If so, then download one of the zipped files: for the Windows world, use the codebrk.zip file, for the Linux world, use the codebrk.gz file, which I had to rename from .tgz to .gz due to Applefritter's website not supporting the tgz file type. You should rename it to tgz before invoking gunzip.
The zip files contain, among other files, an AIFF file for any media player to generate the audio stream you can feed into the cassette TAPE IN port of either the Apple-1 or Apple-II.
The source code is not included, sorry. I don't want to embarrass myself with my poor programming. It does work (I believe) but it is incredibly ugly and inefficient. The core algorithm was written by my teenage self, remember, and so it is far from what I could do today in terms of efficiency and elegance. While I recoded it for the 6502 I saw how utterly inefficient the "evaluation" code was. The translation made it even worse. But it works !
BEWARE THE MONO / STEREO CABLE TRAP !
You should be able to use any audio player but be aware that if you use STEREO audio cables with the MONO inputs of these vintage machines, or MONO cables, one STEREO channel of the player may very likely get shorted to ground (the one on the "ring" of the STEREO plug). If the output amplifier of your audio player has no good built-in short circuit protection then it may get damaged. To play it safe, I recommend you to make a pair of cables specifically for use with the Apple-1 and Apple-II: take one factory made STEREO cable (they are the cheapest, MONO cables are rarer and hence, more expensive) having STEREO plugs at both ends, cut it in half, and install a MONO plug on the end(s). Only connect ground return (the shield) and the one STEREO channel which goes to the tip of the STEREO plug. This one channel connects to the tip of the MONO plug. Now, you have made two special cables for the Apple-1 and the Apple-II and as long as you plug the MONO plug into the Apple, and the STEREO plug in your media player, nothing bad can happen. Here is a photo of such a cable:
SOME PROBLEMS I'VE SEEN
On Windows 7, and on my notebook, the media player is a piece of crap as it sometimes makes audible gaps during playback, and the load will not work. It helped to close all open windows including the media player and restart the media player only. You can listen to the audio for these gaps in case the load fails again. Rinse and repeat. I had no such problems with the media player of Linux Mint. Seems Windows 7 is still not really able to do real multitasking. Even a web browser can freeze the machine up.
When loading on POM1, the Apple-1 emulator, if you want autostart, load the 'codebrk.apl' file with CTRL-L and then the "emulate keyboard entry" option. But this takes a long time to load unless you dial up the output speed. It's better not to use he "emulate keyboard entry" option and give the start command manually: 800R <return>.
If you find any other quirks, let me know.
Comments invited !