1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
-
+
-
+
+
+
-
+
+
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
|
# 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.
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) 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.
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:
$ cd ~/pidp8i ⇠ or wherever the PiDP-8/I source code is
$ cp /path/to/deeper/thought/deeper.c src
You need to make a few adjustments to `deeper.c` to get it to build:
Use your favorite Linux text editor to make a few adjustments to `src/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, found up among the `#include` lines:
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:
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 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.
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.
# Why Not Make This Easy?
|