About The Contest
The first ever Olympiad of Misguided Geeks contest at Worse Than Failure (or OMGWTF for short) is a new kind of programming contest. Readers are invited to be creative with devising a calculator with the craziest code they can write. One lucky and potentially insane winner will get either a brand new MacBook Pro or comparable Sony VAIO laptop.
Entry #100324: The UnLogic Calculator
I guess putting the whole calculator would have been way too slow, even for this contest and way too much work anyways. So I ended up with implementing lots of functions natively, working around bugs in the virtual hardware, while the virtual hardware works around some more or less intentional software problems. Everything is packaged in a nice mix of C (GUI)/C++ (Logic), looking like OO-based design. But you'll soon find out that it's more like a pile of historically grown 'spaghetti'-style code that mostly relies on the correct order of initialization of multiple inherited base classes and their class members.
The hardware simulator supports only one singe type of gate: NAND.
Every other operation is created by combining NAND-gates in different ways. Because this creates huge nets even for quite simple things, there is some basic optimizer in place that removes any double negations. There is also some debug code present to output the generated nets into text files that can be fed into any of the graphviz tools to generate nice pictures. It also features a "logic analyzer" to output the logic levels of a virtual gate sampled to a .vcd file.
Unfortunately I ran out of time, so I wasn't able to put as much parts of the calculator into the virtual hardware as I intended. I also didn't have any time to clean up the code nicely, so there are lots of dead classes and functions. Most of them actually work, but they are just not used or connected to the GUI.
Finally, I "forgot" to handle the window manager's close event, so you have to use the "X" button on the keypad on the calculator UI to shut it down properly... Hope you don't mix it up with the multiplication operator on the bottom *g*