How can you make 16-Bit CPU Emulator in roblox?

Hello devs! today I was thinking of some ideas and came up with the idea to have a fully fledged 16-bit CPU Emulator in roblox. Allowing the user to input code to the interface and if they wanted too, They could play games like Tetris. The only game (off roblox) that has done this (As far as i know) is the canceled Java game by Mojang called 0x10c I know poeple have made something like this. Example: @HooferBevelops and his team made a working gameboy emulator.

Please let me know if:

  • If this is possible.
  • If so how? lol.
3 Likes

While something like this is definitely possible, it would most likely be rather slow for most use cases, due to the amount of performance overhead from emulating assembly code inside Lua which is compiled up from C++.

As for how you’d do it, you’re pretty much on your own there. I don’t think anyone here would just code something of that complexity for you. You’d most likely have to learn how CPUs work at a fundamental level first, and then write an interpreter for 16 bit assembly.

1 Like

Ok thanks! I most likely expected this to not only be very hard but also perform badly.

I will still do some research on the basic fundamentals like you said:

You’d most likely have to learn how CPUs work at a fundamental level first, and then write an interpreter for 16 bit assembly.

Honestly though it might not be worth it. For me anyways. Im not very experienced with Lua and for that matter any other language. Im learning though!

However im not going to call it day for this idea just yet. I will “Try”.

Again, Thanks for the fast response!

I don’t know how to do it but what games will we be able to emulate in your game?

Here’s one I saw that’s on roblox: Gameboy Emulator v2 [Open Source] - Roblox

Well… I dont know… Its more of a test/idea i had. Idk if it will ever be a game. But if i get something working you could play any 16bit game maybe…

cool! I hope the games I’m thinking of are 16 bit.

Our emulator you mentioned was a fork of the LuaGB emulator.(GitHub - zeta0134/LuaGB: A gameboy emulator written in pure Lua. Work in progress.)

Creating an emulator in Lua is the same as creating an emulator in any other language, except Lua in Roblox is not as low-level as something like C++. It is totally possible to make this in Lua, it just requires a LOT of research on how emulators work. I suggest looking into that first, and then looking into how other people do it in other languages, and keep practicing from there.

1 Like

If you would like to start simulating instruction sets or learning about CPUs, I would recommend checking out Ben Eater’s YouTube channel. He has a series on building an 8-bit cpu from scratch. It’s a great series and a good starting point if this topic interests you. I have built his CPU by hand and even simulated it.

Microprocessors are definitely an interesting area. I’d say to choose an instruction set that you can wrap your head around and then write it out in code.

1 Like

If you wanted to make a gameboy emulator, you could emulate registers and memory, considering the Game Boy only had a resolution of 160x144 and a memory size of 8KiB but, technically 64KiB according to Wikipedia, therefore, it should be entirely possible to make a Game Boy emulator in Roblox and have a working display too.

Some useful resources I found:

Game Boy Manual.pdf (291.7 KB)
(I uploaded this, the site I downloaded it from used http, here’s the site if you want to download it from there http://marc.rawer.de/Gameboy/Docs/GBCPUman.pdf)

we got x86 cpu emulator on lua, if anyone can port it into roblox…