PiDP-8/I Software

Artifact [63fc34472d]
Log In

Artifact 63fc34472df9aa8c672d9a57dcd1640049825068:

Wiki page [Incandescent Thought] by tangent 2019-04-01 14:57:25.
D 2019-04-01T14:57:25.812
L Incandescent\sThought
N text/x-markdown
P 154e90e144443bb09fa480d2bed9a801b9ade83c
U tangent
W 5564
# Applicability

This document applies to the tip-of-trunk version of the PiDP-8/I software. If you are still running the last stable release, v2017.12.22, you'll need to either [upgrade](/#updating) or switch to the [last version of this document as of the time of that stable release](/info/37b9507f98f).


# The Situation

In February 2016, Norman Davie released a program he called [Deeper Thought](https://groups.google.com/forum/#!msg/pidp-8/tbciVNoZJbw/AMjywRKLAwAJ) after an earlier program by Steve Gibson called [Deep Thought](https://www.grc.com/pdp-8/deepthought-sbc.htm). 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 its switches.

Davie's program has been [forked several times](https://github.com/timdawg/Deeper-Tought-2/network), 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) (ILS) 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.

When I rewrote the ILS, one of the things I did was add a compatibility interface for programs like Deeper Thought which remain dependent on the old `gpio.c` module interface. This article describes the steps you must take to build a version of Deeper Thought against our new ILS.


# 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/misc` subdirectory:

    $ cd ~/pidp8i                  ⇠ or wherever the PiDP-8/I source code is
    $ cp /path/to/deeper/thought/deeper.c src/misc

Use your favorite Linux text editor to make a few adjustments to `src/misc/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 these lines, found up among the `#include` lines:

        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. Replace the block of code beginning with the `pthread_create()` call and ending with `sleep(2)` — inclusive — with the following:

        pidp8i_simple_gpio_mode = 1;
        if (start_pidp8i_gpio_thread ("Deeper Thought 2") != 0) exit (EXIT_FAILURE);

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're happy with your current configuration, this will do the trick:

    $ make reconfig

Otherwise, re-read `README.md` and run `configure` manually:

    $ ./configure --with-your-new-option-set

Either way, among the lines in the `configure` script output should be this one:

    Found Deeper Thought; building it against ILS GPIO module

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.


# Disabling the PiDP-8/I Simulator

If you want Deeper Thought to run by default instead of the PiDP-8/I simulator, say:

    $ sudo systemctl stop pidp8i
    $ sudo systemctl disable pidp8i

The Deeper Thought installer script will mark its service to start by default. If you don't give those two commands, Deeper Thought will crash on boot because it can't grab control over the GPIO lines going to the PiDP-8/I front panel while the PiDP-8/I simulator is running.


# Reverting to Boot with the PiDP-8/I Simulator

To revert the changes made in the previous section and mark Deeper Thought to not start on boot, say:

    $ sudo systemctl stop deeper
    $ sudo systemctl disable deeper
    $ sudo systemctl enable pidp8i
    $ sudo systemctl start pidp8i


# 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.


## License

Copyright © 2017-2018 by Warren Young. This document is licensed under the terms of [the SIMH license][sl].

[sl]: https://tangentsoft.com/pidp8i/doc/trunk/SIMH-LICENSE.md
Z ae9781a66c21d4a905dda14f1b64bcc4