# Gameboy Emulator

**URL:** <https://forum.makecode.com/t/gameboy-emulator/30919>\
**Category:** Show & Tell\
**Created:** [September 30, 2024, 1:40pm UTC](https://forum.makecode.com/t/gameboy-emulator/30919 "2024-09-30T13:40:32Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![nbarkhina](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/nbarkhina/32/17372_2.png) [@nbarkhina](https://forum.makecode.com/u/nbarkhina)\
**Post date:** [September 30, 2024, 1:40pm UTC](https://forum.makecode.com/t/gameboy-emulator/30919/1 "2024-09-30T13:40:32Z")

</div>

> **[gameboy-makecode](https://arcade.makecode.com/S19799-34960-64270-00041)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

Hi everyone,

I wanted to share my Gameboy Emulator that I wrote using Microsoft MakeCode. I took on this project mainly as a challenge and to push the limits of what is possible with MakeCode 🙂

I really love this platform and have used it to work on some games with my 7 year old daughter. It got me thinking about what could be possible. The MakeCode screen (at 160x120) is very similar to the Gameboy screen (at 160x144). So I basically had to squeeze it slightly in the vertical direction but horizontally you don’t lose any pixels.

That being said the emulator itself currently runs pretty slow, averaging around 20-25 frames per second on most games using the simulator. On real hardware it’s even worse at around 2 FPS -

 ![gbscreen.PNG](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/6/4/647cd62f7c5a4ad75d32df6958acdb9555308419.jpeg)

The game included is an unfinished demo I had been working on. In order to load your own roms look at the top of the code for the instructions. Basically you need to convert it to a MakeCode Image for it to work. When I originally started working on the project I stored the rom data as a simple number array but the app would not compile saying the program was too large. This could be some kind of memory constraint. However after encoding it into an image it worked. Possibly this is because the hardware stores images/assets in another part of the memory that is larger? not sure but that is my theory. So the image approach worked fine since each pixel is 4 bits (16 colors) so I used 2 pixels to represent each byte.

Anyway, I’d love to get some feedback. Also any tips on how I can improve the performance would be highly welcome. All of the rendering is done by using setPixel directly to the background image. Though I think just emulating the Gameboy CPU which originally ran at around 4mhz is the main bottleneck. I am relatively new to this platform so would love to hear what people think and if there is some way to squeeze more performance out of it.

Thanks!

---

<div class="post-metadata">

**Author:** ![Jedi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jedi/32/14307_2.png) [@Jedi](https://forum.makecode.com/u/Jedi)\
**Post date:** [September 30, 2024, 5:02pm UTC](https://forum.makecode.com/t/gameboy-emulator/30919/2 "2024-09-30T17:02:20Z")

</div>

wow! this is amazing! this will be AWESOME for my meowbit

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/b/e/be5d16ea94f4cfad012de3c6ddf7c5b67f30e3a3.png)

you could change the screen size of the simulator using

```js
namespace userconfig {
    export const ARCADE_SCREEN_WIDTH = 160
    export const ARCADE_SCREEN_HEIGHT = 144
}

```

i did run into an issue, due to the size limit of makcode images some roms dont fit, such as super mario land 2.

---

<div class="post-metadata">

**Author:** ![Brohann](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/brohann/32/17380_2.png) [@Brohann](https://forum.makecode.com/u/Brohann)\
**Post date:** [September 30, 2024, 5:02pm UTC](https://forum.makecode.com/t/gameboy-emulator/30919/3 "2024-09-30T17:02:29Z")

</div>

You might get better speed using image.setrows instead of setpixel!  
Amazing job by the way.

---

<div class="post-metadata">

**Author:** ![DangerNoodle](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/dangernoodle/32/14797_2.png) [@DangerNoodle](https://forum.makecode.com/u/DangerNoodle)\
**Post date:** [September 30, 2024, 5:02pm UTC](https://forum.makecode.com/t/gameboy-emulator/30919/4 "2024-09-30T17:02:37Z")

</div>

what you can do (i forgot how) is to change the button color to white to match it!

---

<div class="post-metadata">

**Author:** ![Brohann](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/brohann/32/17380_2.png) [@Brohann](https://forum.makecode.com/u/Brohann)\
**Post date:** [September 30, 2024, 5:54pm UTC](https://forum.makecode.com/t/gameboy-emulator/30919/5 "2024-09-30T17:54:47Z")

</div>

I think @DangerNoodle is referring to [[Tutorial] How to Change the Simulator Color](https://forum.makecode.com/t/tutorial-how-to-change-the-simulator-color/27571)

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [September 30, 2024, 7:04pm UTC](https://forum.makecode.com/t/gameboy-emulator/30919/6 "2024-09-30T19:04:30Z")

</div>

@nbarkhina images, strings, numbers, etc. do indeed get stored in the flash storage of the game rather than in memory which has a lot more available space. declared arrays don’t get the same treatment, so they end up taking memory (and also cause the code generation to be much less efficient).

however, instead of images you might find it easier to use buffers for storing data. the syntax for buffers looks like this:

```auto
let myBuffer = hex`0123456789ABCDEF`

```

data declared this way is also stored in flash, but buffers are much easier to get bytes (and other number types) out of, plus you can put them all on a single line 🙂

for reference, here’s a code snippet that you can use to convert a Uint8Array into the string format that the `hex` syntax expects: [https://github.com/microsoft/pxt/blob/35170650487739b2d029ecdece19e4716e8176d4/pxtlib/util.ts#L966](https://github.com/microsoft/pxt/blob/35170650487739b2d029ecdece19e4716e8176d4/pxtlib/util.ts#L966)

---

<div class="post-metadata">

**Author:** ![Kiwiphoenix364](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kiwiphoenix364/32/14368_2.png) [@Kiwiphoenix364](https://forum.makecode.com/u/Kiwiphoenix364)\
**Post date:** [September 30, 2024, 9:09pm UTC](https://forum.makecode.com/t/gameboy-emulator/30919/7 "2024-09-30T21:09:32Z")

</div>

Very cool! As @brohann said, setRows is very useful, especially combined with a buffer and a renderable

---

<div class="post-metadata">

**Author:** ![robotosaurus](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/robotosaurus/32/19294_2.png) [@robotosaurus](https://forum.makecode.com/u/robotosaurus)\
**Post date:** [September 30, 2024, 9:09pm UTC](https://forum.makecode.com/t/gameboy-emulator/30919/8 "2024-09-30T21:09:42Z")

</div>

This is crazy! I’d never thought I would be playing pokemon inside makecode arcade.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/8/3/83ffab8f4bf55b7f5978d657a2d024db622a2d59.png)  
Let alone a full gameboy emulator!

---

<div class="post-metadata">

**Author:** ![hogan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/hogan/32/17525_2.png) [@hogan](https://forum.makecode.com/u/hogan)\
**Post date:** [October 10, 2024, 5:49pm UTC](https://forum.makecode.com/t/gameboy-emulator/30919/9 "2024-10-10T17:49:22Z")

</div>

awesome!

---

<div class="post-metadata">

**Author:** ![AqeeAqee](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/aqeeaqee/32/5424_2.png) [@AqeeAqee](https://forum.makecode.com/u/AqeeAqee)\
**Post date:** [October 14, 2024, 5:26pm UTC](https://forum.makecode.com/t/gameboy-emulator/30919/10 "2024-10-14T17:26:41Z")

</div>

Really cool !

---

<div class="post-metadata">

**Author:** ![CodeTycoon](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/codetycoon/32/27588_2.png) [@CodeTycoon](https://forum.makecode.com/u/CodeTycoon)\
**Post date:** [November 20, 2024, 5:04am UTC](https://forum.makecode.com/t/gameboy-emulator/30919/11 "2024-11-20T05:04:57Z")

</div>

Sorry to ask, but is there any unnecessary code in here? I’ve been trying to cut down some of the code to use less storage space so that it would fit on my Meowbit. Thanks!

---

<div class="post-metadata">

**Author:** ![recamse](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/recamse/32/27879_2.png) [@recamse](https://forum.makecode.com/u/recamse)\
**Post date:** [January 8, 2026, 5:37pm UTC](https://forum.makecode.com/t/gameboy-emulator/30919/12 "2026-01-08T17:37:41Z")

</div>

![obraz_2026-01-07_174307749](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/d/1/d101956b066dac01cbdbaf9eaff957a15940c894.png)my biggest dream just apeared​:smiling\_face\_with\_tear:🥲

---

<div class="post-metadata">

**Author:** ![recamse](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/recamse/32/27879_2.png) [@recamse](https://forum.makecode.com/u/recamse)\
**Post date:** [January 8, 2026, 5:37pm UTC](https://forum.makecode.com/t/gameboy-emulator/30919/13 "2026-01-08T17:37:48Z")

</div>

i wonder witch game can be uploaded to makecode arcade

---

<div class="post-metadata">

**Author:** ![Jedi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jedi/32/14307_2.png) [@Jedi](https://forum.makecode.com/u/Jedi)\
**Post date:** [January 10, 2026, 1:46pm UTC](https://forum.makecode.com/t/gameboy-emulator/30919/14 "2026-01-10T13:46:30Z")

</div>

how did you do it?

---

<div class="post-metadata">

**Author:** ![recamse](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/recamse/32/27879_2.png) [@recamse](https://forum.makecode.com/u/recamse)\
**Post date:** [January 10, 2026, 9:33pm UTC](https://forum.makecode.com/t/gameboy-emulator/30919/15 "2026-01-10T21:33:26Z")

</div>

Try using micro SD and this photo is just a screenshot from simulator

---

<div class="post-metadata">

**Author:** ![BlueYoshi507](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/blueyoshi507/32/32630_2.png) [@BlueYoshi507](https://forum.makecode.com/u/BlueYoshi507)\
**Post date:** [January 11, 2026, 10:08pm UTC](https://forum.makecode.com/t/gameboy-emulator/30919/16 "2026-01-11T22:08:05Z")

</div>

I made a not so good version of this game yrs ago, literally, it’s just some tests. I recreated most of the physics.

> **[Super Mario Land 2 - Makecode](https://arcade.makecode.com/S94148-49495-53821-00847)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![JtSpeedRun](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jtspeedrun/32/33167_2.png) [@JtSpeedRun](https://forum.makecode.com/u/JtSpeedRun)\
**Post date:** [January 12, 2026, 6:44pm UTC](https://forum.makecode.com/t/gameboy-emulator/30919/17 "2026-01-12T18:44:10Z")

</div>

This is really impressive, you should make a topic for it!

---

<div class="post-metadata">

**Author:** ![Brohann](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/brohann/32/17380_2.png) [@Brohann](https://forum.makecode.com/u/Brohann)\
**Post date:** [January 12, 2026, 6:44pm UTC](https://forum.makecode.com/t/gameboy-emulator/30919/18 "2026-01-12T18:44:18Z")

</div>

I made a version with better performance using image.setRows but It’s useless because now the screen is flipped 90 degress because apparently setRows secretly means setColumns

---

<div class="post-metadata">

**Author:** ![Vegz78](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/vegz78/32/1201_2.png) [@Vegz78](https://forum.makecode.com/u/Vegz78)\
**Post date:** [January 21, 2026, 5:33pm UTC](https://forum.makecode.com/t/gameboy-emulator/30919/19 "2026-01-21T17:33:17Z")

</div>

This is so cool, @nbarkhina! -Impressive work!

Looking forward to @Brohann’s sped up version eventually, too!

---

<div class="post-metadata">

**Author:** ![IAmMyGuy21th](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/iammyguy21th/32/16978_2.png) [@IAmMyGuy21th](https://forum.makecode.com/u/IAmMyGuy21th)\
**Post date:** [February 17, 2026, 6:15pm UTC](https://forum.makecode.com/t/gameboy-emulator/30919/20 "2026-02-17T18:15:45Z")

</div>

you should make the game be stored in an asset, like assets.image`game` or a buffer or something. also I want this on my meowbit, any way to reduce storage size?

[Next page](https://forum.makecode.com/t/gameboy-emulator/30919.md?page=2)
