SHENZHEN I/O

SHENZHEN I/O

26 ratings
ROM, RAM, and the Lookup Table (WIP)
By lisamariefan
This guide is recommended for people at least a few puzzles in the game, though it can be to benefit of anyone really. Sometimes you need to load a value based on an input, and have too many options to rely on your simple MC family chips. Or sometimes you need to write a lot of values for later use. RAM and ROM chips can be helpful for this, but to get the most out of these parts we need to understand how the memory pointer works and how to control it.

This guide will be developed over the coming days as I find more motivation to finish it, because I truly believe that understanding and trying to master your memory chips is crucial to mastering this game.
   
Award
Favorite
Favorited
Unfavorite
Manipulating The Memory Pointer(s)
To get the most out of your memory chips, it's crucial to understand how the memory pointers works. One quick thing before we begin though: Instead of memorizing the chip numbers, know that the yellow memory cells are for the RAM chip and the blue memory cells are the ROM chip.

At first glance if you read the literature on the chips seems fairly straightfoward. The memory pointers start at location 0. This pointer changes in two different ways. The first is by accessing the corresponding data pin - this includes writing and reading for RAM, but just reading for ROM (If you mess up and try to write to ROM data, your program deadlocks.) The chip will loop back to address 0 when you write/read from address 13.

Reading what address you're on (which does have it's use) does not increment the memory pointer, and can be useful (TODO: Expand on an example of the use of reading address.)

Now here's the REALLY interesting part: Did you know that you can send address values outside of the range 0-13? For positive numbers, this just means that the chip will apply a modulo 14 operation to your address. Note that negative numbers CAN be sent to the address pins (-1 is 13, -2 is 12, etc.) and will loop in much the same fashion. Keep this in mind because it does have a use in our lookup tables to avoid a memory collision (where too different conditions that should be getting different values are referencing the same point in memory).
Lookup Tables - The Basics: ROM Chips
So as you advance through Shenzhen I/O you will eventually come across puzzles where you can have a number of different (predetermined) values that you will need to decide upon one or more of your inputs. Now, seeing how your board space and code space is limited, handling all these different values through chips is NOT the smartest idea.

A lookup table is our attempt to allow us to do very simple to no manipulations on our input that we can then use as an address to a chip. Please note that some of the examples I will be providing are technically spoilers (based on solutions I'VE devised), though I will try to minimize context in explaining them.

TODO: Provide examples with screenshots and elaborate.
Combining a chip with the DX300 - compressing data.
So one particularly useful thing about the memory chips is the ability to store an xbus signal for the DX300 chips. What's even more useful is how the DX300 chip decodes an xbus signal coming to it. Instead of thinking of values as merely as 1 and 0 for what you can feed into each "column" of input, you can think of it as "0" or "greater than 0." That means that 301 and 101 are treated as exactly the same by the DX300 chip. Knowing this, we can encode extra information into numbers being sent to a DX300, such as a timer for multiple pulses. We do have to be careful when doing this though, as improper coding can lead to a 0 rolling over to a 9 and getting an incorrect or unwanted result!

Another use of the DX300 in conjunction with a memory chip is to have "overlapping memory." In one of the late game puzzles (second campaign) you have several different patterns that you need to send to some outputs. This becomes a challenge because you have to have a system that can do the both the normal patterns and the mirror of the patterns and there are several asymetrical patterns. To help deal with this issue, we can do something a little more advanced with out table. We can have similar parts of the pattern overlap (to be fair it is a little bit more compicated than this as, at least in my implementation, time valeus had to be encoded separately)! In this fashion, the pattern that we actually want to create can be accessed by which point in the table we decide to enter into (we read a known number of times). Different entry points give different patterns.
4 Comments
emacs 4 Feb, 2021 @ 1:59am 
neat info thanks
lisamariefan  [author] 8 Jun, 2018 @ 8:59pm 
I guess so, but designs can also check known hardcoded addresses if the design calls for it, meaning you should only have to test the address pin against this known address instead of storing it unless you can't get away with hardcoding table positions like that.

You can also jump to a known starting address and just write code that will send data a known number of times.
lisamariefan  [author] 7 Jun, 2018 @ 10:23pm 
Your code is very buggy and/or pointless btw. Done is in no way conditional, and without further context you jump there every time as you test the address pin after setting it. Even if you did execute the data add, done still executes and clears things and the address is reset in next loop


Also testing the address does not increment it, meaning a known starting address can be hardcoded and designed around OR stored and tested against, depending on how you approach a probem.
lisamariefan  [author] 7 Jun, 2018 @ 9:03pm 
That is true. I also like a terminating value like 0 or -1, depending on the code appication.