TIS-100 Scatterplot viewer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| This design was trying to be compact and (dare I say it?) modular, not fast. | |
| The underlying observation is that both the + and the x plot 5 dots. | |
| So try to make use of that fact. | |
| It's easier to explain this bottom-up. | |
| Node 9 (5X PLOTTER) takes a command stream of the form: | |
| color | |
| 5 pairs (dx,dy) | |
| At the start, (x,y) stored in (ACC,BAK) is 0. | |
| Color is sent to 10 (PLOT SEQUENCER) which feeds it back to us 5x, with control input. | |
| The rest is a loop that adds dx to current x, dy to current y, then plots a single | |
| point with given color. After looping 5x we need to reset ACC and BAK. | |
| Note we use ANY to grab the color, and then LAST after that to keep | |
| consuming data from the node that generated it. This is a neat way of getting | |
| synchronization without needing an explicit mux node or more direct sequencing | |
| logic. | |
| Node 10 (PLOT SEQUENCER) is trivial. | |
| WHITE PLUS and RED X are easy. Fetch the first coord; if we get one, start sending | |
| commands to the 5X PLOTTER. This is just initial X,Y and then delta coord pairs. | |
| The implicit synchronization is the whole trick here. | |
| DISPATCHER has to decode the command stream and forward the X,Y coords to either | |
| WHITE PLUS or RED X. No interesting design work here, you just have to do it. | |
| ---- | |
| @0 | |
| @1 | |
| MOV UP,DOWN | |
| @2 | |
| @3 | |
| @4 | |
| #DISPATCHER | |
| S:MOV UP,ACC | |
| SWP | |
| MOV UP,ACC | |
| SWP | |
| JRO UP | |
| JMP P | |
| X:MOV ACC,RIGHT | |
| SWP | |
| MOV ACC,RIGHT | |
| JMP S | |
| P:MOV ACC,DOWN | |
| SWP | |
| MOV ACC,DOWN | |
| @5 | |
| #RED X | |
| MOV LEFT,ACC | |
| MOV 4,DOWN | |
| MOV ACC,DOWN #X0 | |
| MOV LEFT,DOWN #Y0 | |
| MOV -1,DOWN | |
| MOV -1,DOWN | |
| MOV 2,DOWN | |
| MOV 0,DOWN | |
| MOV 0,DOWN | |
| MOV 2,DOWN | |
| MOV -2,DOWN | |
| MOV 0,DOWN | |
| @6 | |
| @7 | |
| @8 | |
| #WHITE PLUS | |
| MOV UP,ACC | |
| MOV 3,RIGHT | |
| MOV ACC,RIGHT #X0 | |
| MOV UP,RIGHT #Y0 | |
| MOV 0,RIGHT | |
| MOV -1,RIGHT | |
| MOV 0,RIGHT | |
| MOV 2,RIGHT | |
| MOV -1,RIGHT | |
| MOV -1,RIGHT | |
| MOV 2,RIGHT | |
| MOV 0,RIGHT | |
| @9 | |
| #5X PLOTTER | |
| MOV ANY,RIGHT #COL | |
| ADD LAST #X+=DX | |
| MOV ACC,DOWN | |
| SWP | |
| ADD LAST #Y+=DY | |
| MOV ACC,DOWN | |
| SWP | |
| MOV RIGHT,DOWN | |
| MOV -1,DOWN | |
| JRO RIGHT | |
| MOV 0,ACC | |
| SAV | |
| @10 | |
| #PLOT SEQUENCER | |
| MOV LEFT,ACC #COL | |
| MOV ACC,LEFT | |
| MOV -8,LEFT | |
| MOV ACC,LEFT | |
| MOV -8,LEFT | |
| MOV ACC,LEFT | |
| MOV -8,LEFT | |
| MOV ACC,LEFT | |
| MOV -8,LEFT | |
| MOV ACC,LEFT | |
| MOV 1,LEFT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment