
RustBoyAdvance-NG: GameBoy Advance emulator and debugger, written in rust - ingve
https://github.com/michelhe/rustboyadvance-ng
======
simias
Rust is a nice language for emulators in my experience, although managing the
large global state emulators require while making the borrow checker happy and
not damaging performance requires a bit of planning (unless you're willing to
litter your code with unsafes).

My strategy in the end is simply to stuff the entire state in a struct that I
pass around everywhere, using a more functional style instead of class
methods. This way I don't have to borrow anything and I have access to the
full state everywhere in the code. It doesn't make for clean OOP-style
encapsulation but I found that doing that was too complicated in an emulator,
you simply have too many interactions between the various modules of most
consoles. For instance the DMA can write data to the GPU which can trigger an
IRQ in the interrupt controller which can change the CPU state which can
modify the state of a coprocessor which can lead to registers being banked
into RAM etc...

Besides, the architecture of an emulator is generally constrained by the
underlying hardware, so it's rare that you have to do big refactors. Having
leaky interfaces is not much of a problem in practice because you don't really
have to worry about "but what if tomorrow I need to emulate a Game Boy Advance
with a very different GPU?".

While we're showing off Rust emulator projects I've spent the last few days
writing an emulator for the PlayStation's CD-ROM sub-CPU:
[https://gitlab.com/flio/psx_cd](https://gitlab.com/flio/psx_cd) . I hope to
be able to integrate it into my PlayStation emulator when it's done, which
would save me from having a super hacky high level CD interface like most
other PSX emulators out there.

~~~
AlchemistCamp
> using a more functional style instead of class methods

Does Rust even have classes?

~~~
timw4mail
`impl` methods with `self` parameters are basically class methods in feel.

------
rvz
Great project! But other than it being 'written in Rust' can someone explain
what is interesting about yet another Gameboy Advance emulator using SDL2? I'm
guessing its WASM support?

I think we're all capitalising on the HN algorithm gearing towards Rust-
related posts which can only be a great thing for those who absolutely love
Rust <3\. Perhaps I should be a town crier for the Rust project to market all
things Rust.

𝔒𝔶𝔢𝔷!, 𝔒𝔶𝔢𝔷!, 𝔒𝔶𝔢𝔷! 𝔄𝔫𝔬𝔱𝔥𝔢𝔯 𝔤𝔯𝔢𝔞𝔱 ℜ𝔲𝔰𝔱 𝔭𝔯𝔬𝔧𝔢𝔠𝔱!

~~~
the_pwner224
> 𝔒𝔶𝔢𝔷!, 𝔒𝔶𝔢𝔷!, 𝔒𝔶𝔢𝔷! 𝔄𝔫𝔬𝔱𝔥𝔢𝔯 𝔤𝔯𝔢𝔞𝔱 ℜ𝔲𝔰𝔱 𝔭𝔯𝔬𝔧𝔢𝔠𝔱!

What the hell are those? I looked at each letter (Unicode 1D5{12,36,22,37}),
and apparently it spells out Oyez?

~~~
qznc
[https://en.wikipedia.org/wiki/Oyez](https://en.wikipedia.org/wiki/Oyez)

Oyez (/oʊˈjɛz/, /oʊˈjeɪ/, /oʊˈjɛs/, more rarely with the word stress at the
beginning) is a traditional interjection said two or three times in succession
to introduce the opening of a court of law, especially in Great Britain. The
interjection is also traditionally used by town criers to attract the
attention of the public to public proclamations.

~~~
outadoc
It's French in origin, FYI.

~~~
ev0xmusic
yes it is

------
idoncarfb
So another post about Rust. Nice.

