Making an Emulator in JavaScript?

Rate this content
Bookmark

FAQ

The original topic was building a Game Boy emulator in JavaScript.

JavaScript is not ideal because emulation runs on a very low level, and JavaScript, being a high-level language, is not suited for such tasks.

Hexadecimal notation uses numbers 0-15, represented as 0-F, to efficiently use memory space, as writing F is shorter than writing 15.

Chip 8 is a very old console from the 70s, known for being simple and having documented specs online, making it ideal for learning emulation.

Sarah found building a Game Boy emulator harder than expected and decided to focus on building an emulator in JavaScript, sharing the learning experience.

The two types of emulation mentioned are hardware emulation and software emulation.

The four main components are hardware, screen, keyboard or gamepad, and sound.

Sarah works as a product engineer at ePilot.

Emulation is when a computer pretends to be something else, such as a PlayStation 1, through software or hardware, often used for video games and operating systems.

Sarah advises not to provide ROMs or BIOS, and to avoid emulating consoles that are still in production to avoid legal issues.

Sara Vieira
Sara Vieira
29 min
13 Dec, 2024

Comments

Sign in or register to post your comment.
Video Summary and Transcription
Hello, everyone. Thank you for being here instead of the other talk. Emulation is when something pretends to be something else, like a computer pretending to be a PlayStation 1. There are two types of emulation: hardware emulation and software emulation. Software emulation is when the software mimics the behavior of a console. JavaScript is not the ideal language for emulation, but it can still be used. The speaker built an emulator for Chip 8, a simple console from the 70s, as a fun project. The emulator focuses on the screen and utilizes Canvas. The Chip 8 screen is small, measuring 64 by 32, and is monochrome. The CPU and memory are important components in emulation, and understanding hexadecimal notation and bitwise operators is crucial. The speaker explains the use of hexadecimal notation and bitwise operators in manipulating bytes. Creating a switch statement for instructions is an important step in the emulator development. The legality of emulation is discussed, along with advice on not providing ROMs or proprietary BIOS. Emulation projects can be complex, and reverse engineering consoles is mentioned. The speaker highlights the performance of JavaScript in emulating consoles. They also mention their availability for further questions and provide information on how to follow their work.
Available in Español: Making an Emulator in JavaScript?

1. Introduction

Short description:

Hello, everyone. Thank you for being here instead of the other talk. I wanted to build a Game Boy emulator in JavaScript, but it turned out to be harder than expected. So we'll talk about building an emulator in JavaScript. My name is Sarah, I'm a product engineer at ePilot. We're hiring. I'm originally from Portugal, lived in Berlin for five years. Thank you!

Hello, everyone. Thank you so much for being here instead of the other very cool talk that is happening right now. I'm sorry they put us both at the same time. So if you've seen the schedule before, like two days ago or like a week ago, it actually said building a Game Boy emulator in JavaScript, so we know how that went. But basically, that was my main plan because I thought it would be easy. I was like, I'll just make a Game Boy emulator. Turns out that's really hard. Who would have thunk it, huh?

And basically, I felt like a lot of the stuff that I learned along the way would make a good talk by itself, not because I didn't do it, but because I wanted to give you the best possible talk. So it went from this to just building an emulator in JavaScript. So that's what we're going to talk about. As Nathaniel said, my name is Sarah. I actually do not work at Orama anymore, but I forgot to tell them. I'm a product engineer at a company called ePilot. We're actually hiring. I mean, we're also working. And I'm from Cologne. So come join us. You don't have to join us in Cologne. I live in London. It's fine. I mean, you can also... Cologne sounds nice. You know. Yes. So yeah. Again, I'm originally from Portugal. I lived in Berlin for five years. Hate the airport. But that's about all you need to know about me. Thank you so much.

2. Emulation and Types

Short description:

Emulation is when something pretends to be something else, like a computer pretending to be a PlayStation 1. There are two types of emulation: hardware emulation, where the hardware is the same or similar but not made by the original manufacturer, and software emulation, which is what we'll focus on.

Okay, I want to start the talk by saying that what I'm going to show you is definitely legal. And there are two reasons I put this slide. The reason one is that I always wanted a slide like this in talks that I did. But the reason two is that I think there is a very big misconception about emulation and the fact that it's illegal. And I don't know how in many countries it has become legal or what's the precedent. I know the one in the US. I am not American, but I feel like we're all American in a weird way. So there you go. So in the US, back in 2000, there was a company called Bleep. I swear to God, it's a real company. And they named it Bleep. And they made a PlayStation 1 emulator for Macs, of all things. And they asked Sony for their bias, which was a proprietary Sony thing, so they can make the emulator. Sony said, nine. And they were like, okay, then we'll just make our own. And they made the emulator, released it on MacOS. And there's videos of Steve Jobs being like, we can run video games on a Mac. Not anymore, but you could back in 2000. Now you need a Linux. But yeah. And then Sony sued them. And they were like, you can't do this. And turns out they couldn't, because they didn't have any proprietary code. So we counted it as reverse engineering, which is usually protected by law. If you're wondering what happened to Bleep, Sony bought them and killed the emulator. But they made a crap ton of money. So that's nice. Cool. I'm not a lawyer, though. So don't fuck with Nintendo. Like seriously, don't fuck with Nintendo.

Okay, what is emulation? So emulation, I'm going to say it as, emulation is when something is pretending to be something else. So my computer pretends to be a PlayStation 1, whether that be through software or hardware. And it can be, it's mostly used for video games, but it can also be used for actual operating systems. Like, I think you can run Windows 95 in the browser, which is cursed, but why not? If you can do it. Everything that can be written in JavaScript will eventually be written in JavaScript. I guess TypeScript now. But yeah. So let's say you have this computer, and this computer is like, no, I'm actually a PlayStation. So it can read that code, interpret it, run the instructions it's supposed to run, and do the thing. There are two types of emulation, though, and I want to make sure that we know the difference in what we're actually going to be talking about. So there's hardware emulation, and let's say that you actually know how to make chips. Right? You have that fancy software and you ship everything to the one company that sponsors all the YouTubers. And that's basically, let's say you have a chip for a Game Boy, and you made the exact same parts, so we can actually read the game. It's hardware emulation. The hardware is exactly the same or very similar, just not made by Nintendo, or Sega, or whatever. But this is not what we're going to be talking about. If you are interested in this, something that exists right now that is the most known is called FPGA, and you can buy devices of that. And it's a different type of emulation. There's also software emulation, and that's what we're going to be talking about.

QnA