How I repurposed async await to implement coroutines for a Game Boy emulator
sanjeetnd.com·4h·
Discuss: r/rust
Flag this post

Emulators in Rust with async/await

A few months ago I implemented a(nother) Game Boy emulator in Rust, where I repurposed Rust’s async await into coroutines for fun and no profit.

The Problem

The Game Boy’s hardware consists of several independent components – the CPU, Pixel Processing Unit (PPU), Audio Processing Unit (APU), etc. Each component advances in discrete time steps called M-cycles.

How do you keep the flow of code simple and direct inside each component while still being able to interleave their operations? Here’s what I mean:

![Left image shows 5 M-cycles and different components advancing in parallel on various cycles. Right image shows this simulated in a single-threaded environment by advancing components…

Similar Posts

Loading similar posts...