Oxygen Not Included

Oxygen Not Included

51 ratings
Computer Parts (Automation)
   
Award
Favorite
Favorited
Unfavorite
Compatibility: Base Game, Spaced Out!
File Size
Posted
Updated
4.092 MB
14 Mar, 2022 @ 3:33pm
20 Mar, 2022 @ 2:29pm
8 Change Notes ( view )

Subscribe to download
Computer Parts (Automation)

Description
MORE TO COME!

  • 4-bit register
  • Edge counter (use as a clock)
  • 8-bit multiplexer
  • 8-bit de-multiplexer
  • 8-bit addressable memory module (read gated, so you can combine them to add memory)
  • (NEW) 4-bit FULLY programmable logic gate (ROM / PLC)
  • (NEW) 8-bit stack-based ALU (16 instructions: 4 stack control, 4 arithmetic, 4 bitwise logic, 4 special)


NEW! 8-bit stack-based ALU
Uses a 4-bit opcode:

More detail about the opcodes are available here [github.com].

00 - data / stack
0000 - 0 - standby - (do nothing)
0001 - 1 - peek - (send top of stack to data out)
0010 - 2 - pop - (drop) discard top of stack
0011 - 3 - push - (push data in to top of stack)
01 - special
0100 - 4 - increment - increment top of stack
0101 - 5 - swap - swap top and next (might change)
0110 - 6 - copyfrom - copy from stack index (if 0, returns the current size of the stack)
0111 - 7 - reserved - undecided
10 - arithmetic
1000 - 8 - add - pop and add
1001 - 9 - subtract - pop and subtract
1010 - A - multiply - pop and multiply (pushes high bits on stack first, then low bits)
1011 - B - divide - pop and divide/mod (pushes result on stack first, then remainder (modulus))
11 - bitwise logic
1100 - C - or - pop and or
1101 - D - and - pop and and
1110 - E - xor - pop and xor
1111 - F - xnor - pop and xnor

NEW! 4-bit programmable logic gate (ROM / PLC)
Using the sidescreen, you can map each different possible ribbon input signal to a ribbon output signal.
NOTE: You can also attach a wire to the output, in which case only the first output bit is used. (If you set any of the other output bits to green, the wire will get overload damage.)

4-bit register
Stores 4 bits of binary data from a ribbon.
Has 2 control ports:
  • Write - Updates the stored value with the value from the input.
  • Read - Sends the stored value to the output.

Writes happen before reads, so if both control ports are on, there is no delay.
The "Read Enable" port is so that multiple registers can share the same output ribbon, but you can choose which one will output to it (e.g. by using a demultiplexer).

Disconnected control ports are treated as "on" (green), so depending on which control ports you leave unconnected, it will operate slightly differenly:
  • No control ports connected - Just acts as a "diode" (buffer with no delay) for a ribbon.
  • Only read control connected - The "Read Enable" gate controls whether the input signal passes through to the output or not. So it's a one-way signal gate that you can turn on and off.
  • Only write control connected - Acts like a D-flop, but for 4 bits of data instead of just one.
  • Both connected - Normal: both write-gating and read-gating; a read-gated D-flop.

Edge Counter
Counts the number of times the input signal changes and outputs that in binary to a ribbon.

Mux and DeMux
Connect the output port of the Mux to the input port of the DeMux.
Then attach the output of the Edge Counter to the control ports on each.
The Mux will send one bit per tick of the counter to the DeMux
In 8 ticks of the counter, the DeMux will refresh its output, and it will match the input of the Mux.
The DeMux refreshes when the highest bit on the Edge Counter output changes.

You can string them together to e.g. send 32-bits at a time over a ribbon.

8-bit addressable memory module
Connect data in and address in to the left side, data out to the right side.
Connect a control ribbon to the R / W port.
  • The first bit on the control ribbon is the "read enable" signal; it copies the stored value to the output.
  • The second bit on the control ribbon is the "write enable" signal; it copies the input to the stored value.
  • The third bit on the control ribbon is ignored.
  • The fourth bit on the control ribbon is ignored.

The write enable and read enable bits allow multiple modules to share the same input and output bus, without interfering with each other.

Planned (and being worked on)
  • 8-bit instruction decoder (I already have an instruction set designed that uses the above parts.)

With these additional parts, you should be able to build a fully programmable computer in ONI.

(The stack-based ALU can be used as an instruction sequencer and call stack, as a register, as an ALU, etc. The instruction decoder takes an 8-bit instruction and converts it into two sequential sets of 16 control bits (which determine read channels, write channels, predication, stack pushes and pops, etc. The ROM is where you write the program. I/O with sensors and actuators I'm imagining being memory-mapped, statically.)


Source code available here [github.com].
35 Comments
Pholith 24 Jan @ 4:18pm 
Hello, it would benice to your mods to be translatable
xujunhao6082 11 Jul, 2024 @ 10:48am 
The field sideScreenContentBody doesn't exist after an update published by Klei,which means that the game will crash if you create or load your save with this mod.To solve it,PLib in this mod's folder should update to 4.15.0.0 or further versions.The other approach to it is modifying it with the new version of PLib's code(In PeterHan.PLib.UI.UIDetours,field SS_CONTENT_BODY should be modified),aiming to avoid some possible risks.
hl 7 May, 2024 @ 1:08pm 
can you publish a fixed version somewhere we can use as a local library until this is updated? Thanks!
Pen Aim Kawata.pw 9 Apr, 2024 @ 10:26am 
Hey, I was able to get this working, Thank you SOOOOO much for publicly posting a link to your source code. All I did was update some libraries like PLib and ILMerge, corrected the references for each, and compiled and now it works with the latest version of the game. I'll be making a PR request just to save you some time.
Pen Aim Kawata.pw 8 Apr, 2024 @ 11:15pm 
This mod needs to be updated, Klei changed some ui stuff and now this causes a crash on loading into a world.

Your error good sir, trunicated ofc.
Error in DetailsScreen(Clone).DetailsScreen.OnPrefabInit at (1870.0, 176.0, 0.0)

PeterHan.PLib.Detours.DetourException: Unable to find sideScreenContentBody on type DetailsScreen
at PeterHan.PLib.UI.PUIUtils.AddSideScreenContentWithOrdering[T] (System.String targetClassName, System.Boolean insertBefore, UnityEngine.GameObject uiPrefab) [0x0002b] in <d7d10af00ba3499d9e82b0f7be4e883e>:0
at PeterHan.PLib.UI.PUIUtils.AddSideScreenContent[T] (UnityEngine.GameObject uiPrefab) [0x00000] in <d7d10af00ba3499d9e82b0f7be4e883e>:0
at KBComputing.Patches+SideScreenCreator.Postfix () [0x00000] in <fee2fc88d369467dad6ec17145897c97>:0
at (wrapper dynamic-method) DetailsScreen.DetailsScreen.OnPrefabInit_Patch22(DetailsScreen)
at KMonoBehaviour.InitializeComponent () [0x00068] in
Zaxabock 1 Apr, 2023 @ 6:43pm 
https://ibb.co/0q6Vcmq
If I set it up like that it works? The top input's first bit comes from the bottom's 4th bit and vice versa. Not sure why it's "offset" like that
Zaxabock 1 Apr, 2023 @ 6:20pm 
Is there something wrong with the DeMux at the moment? I've wired it up identically to how the image shows and instructions say, but the wrong pixel lights are lighting up
Ragnaman 7 Feb, 2023 @ 6:28am 
Awesome story to hear.
R. Mueller  [author] 7 Feb, 2023 @ 5:55am 
Gamma_Draconis: I believe the 4-bit register can serve as your "ribbon switch".

Ragnaman: I did not have any sources of inspiration. If anything, it started with my frustration with the lack of a diode gate, and my decision to try making a game mod for the first time. Then I added some more useful parts to thar mod. ('Edge Detecters and diode'), then I went on to make another mod, with more complex parts. (this one).

BTW, I have since designed an instruction decoder for use with the stack-ALU. Then i decided to integrate the two together, since wiring was pretty complex. Never finished that mod, though. Got bored - some things, like UI design, are pretty tedious, with the way some parts of the API are coded. (Not sure if that's Harmony programmers faulr or ONI programmers fault.)
Gamma_Draconis 24 Aug, 2022 @ 3:28pm 
A part that I simply must have is a ribbon switch. It takes a ribbon cable and a wire as inputs, and outputs a ribbon cable, and outputs the input ribbon cable value when the wire input is green, and 0 otherwise.

Ideally it would be 1x3 [width x height] tiles, with the input ribbon on the bottom, the input wire in the middle, and the output ribbon at the top.

This is the biggest thing restricting me from building a full processor with this or anything else. I need it to build a proper bus.