Programmable IC
LadyCailinBot opened this issue ยท 3 comments
CRAFTBOOK-2618 - Reported by cadika_orade
Concept:
A new IC with extendable inputs and outputs, with all logic defined by a player-written script. Effectively a very simple CPU similar to a PIC, Stamp, and Arduino.
Implementation:
The IC would be, in the simplest form, a Single-Input Single-Output IC with a chest on top. To expand, blocks of the same material as the main IC's block can be added to one side and have either blank signs (inputs) or levers (outputs) attached. The IC's program (more on that in a bit) would be written in a book and placed in the chest. Predictably, the self-triggered version would step through the script every 2 ticks, and the regular version would depend on a clock input from the IC's main sign.
The program would be executed one line at a time, stepping through each line of the book. Functions and subroutines would be implemented as more books, where the functions' names are the titles of the books and the main program, if there is more than one, should have its title written on the IC's sign, perhaps on the third line. It is worth noting that, in this manner, a reusable library of functions would be, as a matter of fact, a library. If you are unclear on how this construction would work, I'd be happy to provide a screenshot of a model.
As for the language itself, it would be extremely simple to implement Assembly, which is fairly common to all microprocessors, due to the linearity of logic and simple syntax. Only slightly more difficult would be to implement a simplified flavor of Basic such as PBasic used by the (now antiquated) Basic Stamp. Most challenging of all, though no doubt favorable, would be a simplified version of C, a la the ubiquitous Arduino. Personally, I'd be plenty happy with Assembly and Basic, if possible, for the less-experienced coder.
Lastly is the matter of how these programs would make use of those extra inputs and outputs. In Assembly, the states of each pin would be represented by a bit in a designated register. Outputs would be set by changing the values in the register, and inputs would determine the state of their bits in the register. How large this I/O register would be determined by the maximum number of I/O pins, which can be configured. For Basic, however, a coder would be able to read or address reserved variables named P0, P1, P2, and so forth. I have significant experience with these technologies in the real world (computer engineering major working on a master's degree) and would be happy to help in any way possible.
TL;DR:
Perlstone looks like cryptic rubbish. Replace Perlstone with Assembly or Basic.
Comment by me4502
PerlStone is incredibly similar to Assembly. I plan on implementing a CommandHlper IC, but I have yet to have the time to do so.
Comment by cadika_orade
To be honest, I didn't know what CommandHelper was until I looked at it just now. Given the right implementation, a CommandHelper IC would probably suffice. Thank you.
As a quick note, can CommandHelper manipulate Craftbook variables?