# The Situation

In February 2016, Norman Davie released a program he called [Deeper after an earlier program by Steve Gibson called [Deep The most important difference between these two programs for our purposes here is that instead of running as PDP-8 code within the simulator, as Gibson's program does, Davie's Deeper Thought runs as a native program on the Raspberry Pi, using a version of Oscar Vermeulen's original `gpio.c` module to manipulate the LEDs on the PiDP-8/I's front panel, and read it switches.

Davie's program has been [forked several but this mode of operation remains in all of the versions I've tried.

When Ian Schofield created the [incandescent lamp simulator](/wiki?name=Incandescent+Lamp+Simulator) for the PiDP-8/I, he changed the external interface in a couple of ways which prevented it from being used with any of these versions of Deeper Thought.

Now, about a year after the initial release of Deeper Thought, we finally have a version of the ILS that works with Deeper Thought.


# Modifying `deeper.c`

The first thing you have to do to build any version of Deeper Thought against the current version of the PiDP-8/I software is copy its `deeper.c` file into the PiDP-8/I software's `src` subdirectory.

You need to make a few adjustments to `deeper.c` to get it to build:

1. Add the following line between the big block comment at the top of the file and the `#include` lines following it, at line 156 or so:

        #include "gpio-common.h"

2. Remove the these lines below the `#include` lines:

        typedef unsigned int    uint32;
        typedef signed int      int32;
        typedef unsigned short  uint16;
        typedef unsigned char   uint8;

        extern void *blink(void *ptr); the real-time multiplexing process to start up
        extern uint32 ledstatus[8];     bitfields: 8 ledrows of up to 12 LEDs
        extern uint32 switchstatus[3];  bitfields: 3 rows of up to 12 switches

3. Add these two lines above the call to `pthread_create()`:

        extern int pidp8i_simple_gpio_mode;
        pidp8i_simple_gpio_mode = 1;

4. Replace the word `blink` in the `pthread_create()` line with `gpio_thread`.

With that done, you must reconfigure the software to get it to recognize that `deeper.c` has been added to the `src` subdirectory. If you reconfigure it on a multi-core Pi such as the Pi 2 or Pi 3, it will build against the ILS; otherwise, it will build against the NLS, which may look slightly different from the appearance you get from the old `gpio.c` module, but it probably isn't worth continuing unless you're simply curious.

Now you can try saying `make`. If the software builds, you can now run it as `sudo bin/deeper`.

If you want to install it, I recommend that you build and install Deeper Thought in the normal way, then copy the `bin/deeper` executable you built above over the top of the normal one. This lets you leverage the rest of the installation process shipped with Deeper Thought, such as installing the `deeper` system service.


# Why Not Make This Easy?

You might be wondering why I describe how to modify `deeper.c` to build against the PiDP-8/I software instead of just integrating it and shipping it along with it. It's because this software is not licensed under any open source license, and attempts to get the authors to so license it have been ignored. Therefore, I cannot re-distribute this software, even though it is freely-available on the Internet.