bugzmanov / nes_ebook

A mini book on writing NES emulator using rust lang
https://bugzmanov.github.io/nes_ebook/index.html
385 stars 68 forks source link

I found an error in Chapter3.2 #37

Closed Smart-SangGe closed 3 months ago

Smart-SangGe commented 3 months ago

https://github.com/bugzmanov/nes_ebook/blob/5e1433984362b62f7d4cec4280691c0c8833cb61/src/chapter_3_2.md?plain=1#L88

Here should use immutable reference

bugzmanov commented 3 months ago

Hi! Thanks for bringing this up. You're right, &mut self is not necessary here. However later in the book the same mem_read would be used to access PPU and Joypads. And depending on the address, the read can modify state of a device. I've added a short note clarifying why &mut self was selected here. Hope it makes sense.