r/rust • • Jan 17 '16

I've started livecoding an n64 emulator in Rust! Here's a recording of the first session :)

https://www.youtube.com/watch?v=Fsi9HPcyrU8
119 Upvotes

30 comments sorted by

33

u/pas_mtts Jan 17 '16

I prefer the inner scope style for creating immutable variables that need to be modified initially. For example, your file_buf could be written like this:

let file_buf = {
    let mut file_buf = Vec::new();
    // Do whatever you want to construct file_buf here
    file_buf
};

8

u/yupferris Jan 17 '16

Another nice suggestion! Thanks!

13

u/ThomasWinwood Jan 17 '16 edited Jan 17 '16

I intended to watch this live, but I was far too tired and went to bed at midnight.

  • You do know Rust allows trailing commas in structs and enums? Makes for less messy diffs. :)

  • Might you be able to get away with deriving Default for some parts of the power-on reset, given how much state is left undefined?

11

u/yupferris Jan 17 '16

You do know Rust allows trailing commas in structs and enums?

I did! But I think they're ugly. Silly, I know :)

Might you be able to get away with deriving Default for some parts of the power-on reset, given how much state is left undefined?

I didn't know about deriving Default, or I forgot! Good call. I'll note this for the next one. Thanks!

10

u/mdcox Jan 17 '16 edited Jan 18 '16

That's actually a great reason to use trailing commas...I had always assumed it was just for uniformity and less accidental errors when adding/deleting elements.

11

u/rphmeier Jan 17 '16

Trailing commas being allowed in structs, enums, and tuples are also fantastic for macro implementations.

macro_rules! my_trait_tuple_impl {
    ($($name:ident,)*) => {
        impl<$(
            $name: MyTrait,
        )*>
        MyTrait for ($($name,)*) { ... }
    };
}

9

u/EdoPut Jan 17 '16

3

u/yupferris Jan 17 '16

Oh nice, didn't know about that sub!

5

u/so_you_like_donuts Jan 17 '16

Just a heads up, the latest MIPS instruction set reference and programmer's manual can be found here and here.

I'm not sure how useful they are going to be though, since they may contain stuff that didn't apply to MIPS in 1996.

4

u/yupferris Jan 17 '16

Cool, thanks!

4

u/The_Masked_Lurker Jan 17 '16

Isn't ferris also the name of the rust crab?

4

u/yupferris Jan 17 '16

dude I had no idea!! I looked into this and apparently you're right! Super awesome coincidence; I feel honored now ^ ^

4

u/The_Masked_Lurker Jan 17 '16

First time watching live coding:

It's neat but I kind of wish there was a quick good way to get an accurate transcript. 3 hours is just a tad long and text has better random access!

5

u/yupferris Jan 17 '16

Yeah, I definitely get what you mean! The goal I have is to show the unabridged process, so a transcript is a bit "out of scope" for now, but I might want to do one after. Who knows :)

Anyways, thanks for watching!

3

u/The_Masked_Lurker Jan 18 '16

Yeah I figured typing it all out is too much work, I wish youtube's captions were decent than they could just automagic a transcript/

Secondly it was neat to see reverse engineering in progress

1

u/yupferris Jan 18 '16

Thanks! I hope I can show a lot more reverse engineering, esp. when we get to the RCP!

3

u/onuras Jan 17 '16

I enjoyed watching this. Can't wait for second ep. Keep it up.

1

u/yupferris Jan 17 '16

thank you!!

3

u/lickyhippy Jan 17 '16

That was a fun watch.

Have you considered using Preview.app or something like that for the PDF datasheet? I've found enabling "Table of Contents" view to be invaluable when viewing datasheets like that (only if they are built with an embedded table of contents). If not, you can set up bookmarks for quick access (you seem to be jumping between register definitions, the main index and some other distinct blocks a lot, with a lot of time spent hunting for them each time).

Here's what I mean

Hope to tune in again soon!

2

u/yupferris Jan 17 '16

Good call, I pretty much just found that datasheet and ran with it live, so I didn't think of viewing it outside the browser. Thanks for the tip!

3

u/lickyhippy Jan 17 '16

https://www.dropbox.com/s/vv3biui28tgjg35/Screenshot%202016-01-18%2008.06.50.png?dl=0

That datasheet you had has inbuilt annotations! Just open it in Preview and hit command-option-3. Enjoy!

2

u/yupferris Jan 17 '16

So rad, thanks again :D

2

u/fuzunspm Jan 17 '16

When is the next episode?

2

u/yupferris Jan 17 '16

I'm not entirely sure yet. I'll announce it on my twitter at least: https://twitter.com/ferristweetsnow

1

u/pylbrecht Jan 21 '16

I'm really enjoying watching you coding and working on that emulator. I hope you're planning to do more projects live! Keep it up!

1

u/yupferris Jan 21 '16

Thanks! After the response to this one I don't think I have much choice :D

0

u/[deleted] Jan 17 '16

[deleted]

5

u/yupferris Jan 17 '16

Thank you!

3

u/STR1NG3R Jan 17 '16

I'm also looking forward to the next one. Very interesting first episode.

3

u/yupferris Jan 17 '16

thanks a bunch :D