8 comments

  • debugnik17 minutes ago
    Cool to see F# here! Emulators are a great way to learn a language. On first sight you chose well between more or less idiomatic F# for each job.<p>Some low hanging fruit to reduce allocations: the discriminated unions in Instructions.fs could be [&lt;Struct&gt;], reusing field names to reuse internal fields.<p>Also, minor nitpick but I&#x27;m confused about some of the registers. They are already of type byte, the setters with `a &amp;&amp;&amp; 0xFFuy` don&#x27;t add anything over `member val A = 0uy with get, set`. I&#x27;m guessing this changed over time.
  • cermicelli47 minutes ago
    Finally someone putting in actual human effort to learn something, and not a LLM helped me build X in Y minutes.<p>There is some hope for humanity after all I suppose.
  • yoyohello1321 minutes ago
    I always find emulators written in functional languages impressive. It tends to be much easier to map hardware to an imperative language. I enjoy seeing the functional abstractions people come up with.
    • skrebbel1 minute ago
      Did you look at the code? F# has mutable variables&#x2F;arrays and this uses that for eg memory.
  • z50032 minutes ago
    That&#x27;s so cool! I love F#, but I wrote a little Smalltalk interpreter in it and I can confirm it isn&#x27;t exactly a speed demon for that kind of thing if you use it as intended lol
    • tombert25 minutes ago
      I&#x27;ve found that with F#, I get better performance if I do dumb imperative stuff, but keep the side effects within a function. At that point, the functions can basically be &quot;pure&quot; but you can get decent speed.<p>For example, I usually like using the `Map` data structure, and that&#x27;s a pretty neat immutable structure and is usually fine for most stuff, but when performance becomes critical, it&#x27;s easy enough to break into a boring imperative loop with a regular hash map. If I keep everything contained into one function, I usually can avoid feeling super dirty about it.
    • jackmott4219 minutes ago
      With some care about what features to use and when, F# can be very fast. Which is nice, use functional paradigm when you want, or low level imperative code in hot loops if you need. But yeah if you use linked lists and sequences and immutable data types everywhere it sure isn&#x27;t Rust.
  • MattCruikshank24 minutes ago
    Sorry for the tangent - does anyone have some really zoomed in views of GB, GBColor, GBA screens in operation? I&#x27;d love for retro shaders to be able to more faithfully reproduce.<p>I mean, ideally, we&#x27;d run different color test patterns through, in different lighting conditions, to build a really detailed model, right?
    • Galanwe8 minutes ago
      I guess buying the second hand devices wouldnt be that expensive.
  • hmokiguess44 minutes ago
    F# is super fun, awesome work!
  • Ginop10 minutes ago
    I misread Fem-Boy and I was not understanding the context anymore lol
  • __loam30 minutes ago
    I&#x27;m actually starting a new project to create a gba emulator in zig, and also starting with chip8. I&#x27;m going to skip nand to tetris because I played Turing complete. Cool to see I&#x27;m on the right track!