Live data from Hacker News

Implementing a NES Emulator in Rust

michaelburge.us

71–80 of 93 posts

Re: Implementing a NES Emulator in Rust

#71

Earlier quoted context omitted.

Hm, I’m not sure I see the difference between those concepts, but I do like your framing better.

What my sibling said, but also, that unsafe doesn’t mean you’re free from rules; where safe and unsafe interact, your unsafe code is expected to uphold the safety guarantees that the safe code expects. This matters because of stuff like the article; if you see the other thread, I’m pretty sure (though haven’t verified yet) that this code has UB, even though they’re using unsafe.

Right, which is why I phrased it as a “few restrictions”, I do understand the point you’re making.

I suppose the reason I consider it restrictions is due to things like “in safe code you can not work with raw pointers”. That seems like a restriction to me, but I can see why saying that way is less accurate.

Re: Implementing a NES Emulator in Rust

#76

Shameless plug - for anyone that's interested, I also wrote a NES emulator in Rust a few years back: https://github.com/koute/pinky I even compiled it to WebAssembly: https://koute.github.io/pinky-web/ > The CPU address space has several PPU registers mapped. So the CPU maintains a permanent mutable reference to the PPU. But the top-level Nes object also owns the PPU. I worked around this using Box to assign fixed me…

I'm really enjoying your 6502 emulation code. It feels clean and easy to read.

https://github.com/koute/pinky/blob/master/mos6502/src/virtu...

(I imagine the rest is good too, but 6502 is what I know. :-) )

Re: Implementing a NES Emulator in Rust

#77
post #53

Earlier quoted context omitted.

I am not sure you can not use `unsafe` in an embedded type of project. `unsafe` isn't necessarily bad, but when used at least makes it very clear where extra attention should be paid.

Writing an emulator is not really embedded programming (the target often qualifies as an embedded environment but the host can be any random desktop computer). It's definitely possible to write an emulator without unsafe code. Here's a toy gameboy emulator I wrote a while ago in Rust without any unsafe code: https://github.com/simias/gb-rs Here's a very incomplete PSX emulator with only a single unsafe (which might n…

Are you sure about that?

https://github.com/simias/gb-rs/blob/master/Cargo.toml#L29

Re: Implementing a NES Emulator in Rust

#78
post #15

If you like the subject of emulator and Rust, I suggest you take a look at Ferris youtube : https://www.youtube.com/channel/UC4mpLlHn0FOekNg05yCnkzQ/vid... He stream is development of a Nintendo 64 and Virtual Boy emulator in Rust.

This is amazing. I've long wanted to get into some of this stuff and lately have fallen in love with Rust. I can't wait to watch these videos :D.

Re: Implementing a NES Emulator in Rust

#79

There's also sprocketnes, which was originally written ~6 years ago by pcwalton, who works on rust/servo at Mozilla. It's been kept up to date and it's interesting to see how the project evolved along with the language: https://github.com/pcwalton/sprocketnes

While the project itself is a great resource, the dependencies marked as "*" are unfortunate for a project that is 6 years in the making.

Re: Implementing a NES Emulator in Rust

#80

http://www.michaelburge.us/assets/articles/20190318-nes-emul... Off-topic: Were the "bumping wheel" tiles ever used in the actual game? If so, in which level?

https://tcrf.net/Super_Mario_Bros._3/Unused_graphics#World_8

Apparently not.

Post reply on HN