Files

> > CS2D > Lua Scripts > The 4K CS2D 8-bit machine
Files overviewCS2D overviewLua Scripts overview

English The 4K CS2D 8-bit machine >

19 comments8 kb, 677 Downloads

old The 4K CS2D 8-bit machine

Hador
User Off Offline

∗ This is a fully functional 8-bit computer with 4KB of RAM implemented in CS2D using buildings. ∗

• Free Turing-complete instruction set inside!!! •


> Did anybody ask for this?
> Does anybody need this?
> Does it have any use to anyone?

> Answer to all three: No! But I made it anyway.


> Does it work?
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!



How does this work? >



How do I use this? >



How do I write code? >




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.

Spoiler >
edited 13×, last 26.05.20 12:30:48 pm
Approved by BcY

Download Download

8 kb, 677 Downloads

Comments

19 comments
To the start Previous 1 Next To the start

Log in!

You need to log in to be able to write comments!Log in

old

ImSick4Fun
User Off Offline

Looks epic gonna try this
I like it!

old

Hador
User Off Offline

@user 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.

old

1uP
User Off Offline

Yo what

old

The Dark Shadow
User Off Offline

I couldn't understand anything, Could you introduce us what actually it is?
I like it!

old

G3tWr3ck3d
User Off Offline

intersting
I like it!

old

Hador
User Off Offline

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

old

medeiros
User Off Offline

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!?"
I like it!

old

Dousea
User Off Offline

Damn impressed.
I like it!

old

Hador
User Off Offline

Thanks!

@user 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

old

Elfing
User Off Offline

This is awesome!
I like it!

old

Avo
User Off Offline

I like it! The only thing that is surprising is that
user Hador has written
0: NOP - the program stops

since as far as I remember, NOP usually does nothing, not stops the execution

old

Hador
User Off Offline

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!

old

Pagyra
User Off Offline

Hmm cool... but how can we apply this in practice, why is it created?
I like it!

old

Pseudon
User Off Offline

Lovely and inspiring. Indeed; computation is amazing and I can appreciate your project!
I like it!

old

Hador
User Off Offline

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! cookies

old

VADemon
User Off Offline

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

old

_Lima_
User Off Offline

I didn’t understand anything, but I think it's cool.
I like it!

old

Xirot
User Off Offline

Good job.
I like it!

old

Gaios
Reviewer Off Offline

What the hell..
I like it!
To the start Previous 1 Next To the start