The 4K CS2D 8-bit machine 
19 comments









I haven't tested everything, as this was a 12-hour challenge, but the important parts do, and I will fix bugs if you find any!
That's pretty much it. Please leave a comment if you have any questions and feel free to expand upon this project in any (non-commercial) manner you like, I'd love to hear of anything useful that actually comes from this!
Also, due to math, code can go out of bounds in several places, so be weary of bytes popping up in random places. Literally.
edited 13×, last 26.05.20 12:30:48 pm

Comments
19 comments



Log in!
You need to log in to be able to write comments!Log in
@
The Dark Shadow: It's a computer within CS2D.
The map is used for memory, with different buildings representing different values with the registers at the sides of the players, while the Lua script handles the actual functionality, so it's basically the CPU.
If you press the "execute" button, the program starts running, like a real computer would, but only at ~10Hz with current settings.
The script checks the value of the program counter bytes, which represent a position in memory, and then translates the byte at that position into an operation, with the following bytes used for the data of that operation.
What the script reads might be:
CT Barbed Wire: ADD
Nothing: Register[0]
T Barbed Wire: Register[1]
The script now removes all buildings from Register[0] and replaces them with the buildings that represent the value of Register[0] + Register[1].
Then the program counter is set to the next byte after the data for the last operation and continues there until you press the abort button.

The map is used for memory, with different buildings representing different values with the registers at the sides of the players, while the Lua script handles the actual functionality, so it's basically the CPU.
If you press the "execute" button, the program starts running, like a real computer would, but only at ~10Hz with current settings.
The script checks the value of the program counter bytes, which represent a position in memory, and then translates the byte at that position into an operation, with the following bytes used for the data of that operation.
What the script reads might be:
CT Barbed Wire: ADD
Nothing: Register[0]
T Barbed Wire: Register[1]
The script now removes all buildings from Register[0] and replaces them with the buildings that represent the value of Register[0] + Register[1].
Then the program counter is set to the next byte after the data for the last operation and continues there until you press the abort button.
The name was kind of half-intentional, but when computer memory was still advertised in KB, they were generally called 4K or 8K machines, as memory was the limiting factor and I guess KB was just a bit clunky to use, so it’s definitely also a nod to early 80s computers

Just when I thought I've seen in it all in this tiny lil' 2D game we all love... extremely impressive!
One little thing though: I think you forgot a "B" after "4K" in the title of the upload; when I first read it, I was like "what? A 3840×2160-capable computer running inside of CS2D!?"
One little thing though: I think you forgot a "B" after "4K" in the title of the upload; when I first read it, I was like "what? A 3840×2160-capable computer running inside of CS2D!?"

Thanks!
@
Avo: Thanks for the notice, I wasn't entirely sure about that any more! NOP doesn't technically stop the execution in this implementation, it just infinitely loops on the NOP because it doesn't update the program counter - it doesn't make much of a difference though I guess with the logic implemented in lua, so you could always just add 0 or something like that for the same effect
@

I like it! The only thing that is surprising is that
Hador has written:
since as far as I remember, NOP usually does nothing, not stops the execution

0: NOP - the program stops
since as far as I remember, NOP usually does nothing, not stops the execution

It was created because that's what I felt like doing last Sunday. It has no practical use that I know of, but if you think of one, let me know!
It's probably a deep-seated desire to make all of the knowledge accumulated in a computer science degree useful for something.
But thanks for the positive, if confused feedback, it means a lot!
But thanks for the positive, if confused feedback, it means a lot!


I've never understood this passion, here or in Minecraft, to rebuild computers.
But you get a double-chocolate cookie with milk!
But you get a double-chocolate cookie with milk!



