Programming Temple Run for the Game Boy

86,131
0
Published 2024-04-20
To try everything Brilliant has to offer—free—for a full 30 days, visit brilliant.org/Inkbox/ . You’ll also get 20% off an annual premium subscription.

I programmed Temple Run for the Game Boy and Game Boy Color systems in assembly using the Rednex Game Boy Development System. The Game Boy, first released in 1989, runs of a custom SoC known as the DMG CPU, with its core SM83 being based off the Intel 8080 and Zilog Z80. It has 8KB of WRAM, 8KB of VRAM, along with various I/O and a 160x144px LCD display. Through clever use of the hardware, the Game Boy can display 4 different shades of "gray" (filtered green through the LCD).

Later in 1998, the Game Boy Color was released and featured a new SoC known as the CGB CPU. It featured a CPU capable of running at up to double the DMG's clock speed (at the expense of using more battery power), increased the system's built in WRAM to 32KB, and VRAM to 16KB (Also moving VRAM directly into the SoC package).

Try Temple Run for the Game Boy: notin.tokyo/gameboy/temple
Try Rock Paper Scissors for the Game Boy: notin.tokyo/gameboy/RPS.html

Hardware Analysis: www.copetti.org/writings/consoles/game-boy/

The Game Boy is programmed using RGBASM, which is based on Z80 assembly syntax. Development resources are found below:
Game Boy PAN Docs: gbdev.io/pandocs/
RGBDS GitHub: github.com/gbdev/rgbds
Assembly Programming Guide: gbdev.io/gb-asm-tutorial/
RGBASM Instructions: rgbds.gbdev.io/docs/v0.4.2/gbz80.7
BGR555 color tool: orangeglo.github.io/BGR555/

Rock Paper Scissors in Japan: archive.org/details/cultureofjapanas0000unse
The Culture of Japan as Seen through Its Leisure. pp. 325–326.


Gameboy cartridge by Maxence Béranger from Noun Project
Game Boy by IYIKON from Noun Project
pattern by Yasser Megahed from Noun Project

This video was sponsored by Brilliant

All Comments (21)
  • @Autumnfication
    Next thing you know, Inkbox'll be programming a modern os entirely in pure x64 assembly
  • @Okamikurainya
    For corners, I'd recommend placing a checkpoint. On reaching the checkpoint, the screen will "fade to black", with only the player character on the black screen, before transitioning to reveal the new direction. Since actual turning isn't particularly practical, this would prevent the jarring sharp teleportation and give a moment's respite.
  • @rorcarrot1
    Here's a suggestion to make the turns much less jaring, the player character should rotate and then run off screen and only when it hits the boundry do you refresh with them at the bottom again. As it is, there isnt any real indication you're turning, it just resets. Cool project though i hope you do a follow up with more features from the original!
  • @daviddelgado5553
    Despite having a clear voice, thanks for still going through the effort of adding proper subtitles !!
  • @mronewheeler
    Imagine playing Nintendo Switch but with full color
  • @LightTheMars
    You using Pokemon Gold as the tilemap example really had me look up if I didn't misremember it coming out on the GBC. I wasn't aware it was GameBoy compatible!
  • @Michirin9801
    As a pixel artist and chiptuner, I'm Very Fond of the GBC's hardware, it feels to me on the non-coding side like a NES but better in damn-near every way! I don't even mind the lower resolution, if anything, the biggest bottleneck is the 40 sprites limit, as for that soundchip, lemme tell ya, channel 3, that DAC, that's where its true potential lies! You can do Wonders with it!
  • @angelcaru
    THE I OPERATING SYSTEM OH MY GOD IM DYING
  • @Xevizek
    I've been lately consuming so much Terry Davis' content and on the first sight i've read title as "I made temple OS [...]". Man... Still cool video tho, keep up the good work.
  • @mattgio1172
    This is absolutely insane. The explanation as well as the game are both top notch. Well done!
  • @SkankinMoshPit
    I took a look at your temple run game and I think the reason it won't work on the original GameBoy is because you call the OAM DMA when you are in ROM. On the DMG, you can only access High RAM during the DMA transfer. You need to copy a routine into HRAM on boot that will call the DMA transfer and will wait for it to finish. There's more details about it in the pandoc.
  • @TheBcoolGuy
    Alright, so where is the part where you make the actual game?
  • @frostiikin9893
    Maybe you could do what sonic 1's special stages do and simply fake the rotation by using pre-rotated versions of the tiles and just arranging them in a way that it looks right? You could probably get away with having just one frame of "rotation" just to make it look less abrupt
  • Definitely one of my favorite channels now! Love the clear focus on dev while providing some insight into the hardware.
  • @zaks7
    Finally moving up the ladder, 20 more years and bro will finally find x64 and Unity and unreal :D Love your content man, your NES tutorials got me into learning 6502, I changed my college courses to learn more embedded and low level programming, something so beautiful about the constraints that forces you to be a better coder
  • @Bofner
    I reently got into programming for GB is assembly too! It's a really fun challenge, and I'm particularly attracted to the special features you can use when programming with the Super Game Boy in mind!
  • I think it's fair to call the GameBoy Color a GameBoy 2. The Pocket would have been 1.5 and the Light a 1.75.
  • @sssamson1768
    Why do you only put the music in the left ear?
  • @7projected
    you posted this as soon as i started getting into gb development