I built a Game Boy emulator in F#
11–20 of 84 posts
Re: I built a Game Boy emulator in F#
#12Sorry for the tangent - does anyone have some really zoomed in views of GB, GBColor, GBA screens in operation? I'd love for retro shaders to be able to more faithfully reproduce. I mean, ideally, we'd run different color test patterns through, in different lighting conditions, to build a really detailed model, right?
Re: I built a Game Boy emulator in F#
#13I 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.
Re: I built a Game Boy emulator in F#
#14Re: I built a Game Boy emulator in F#
#15Re: I built a Game Boy emulator in F#
#16I 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.
Did you look at the code? F# has mutable variables/arrays and this uses that for eg memory.
Re: I built a Game Boy emulator in F#
#17Finally someone putting in actual human effort to learn something, and not a LLM helped me build X in Y minutes. There is some hope for humanity after all I suppose.
Re: I built a Game Boy emulator in F#
#18That's so cool! I love F#, but I wrote a little Smalltalk interpreter in it and I can confirm it isn't exactly a speed demon for that kind of thing if you use it as intended lol
I'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 "pure" but you can get decent speed. For example, I usually like using the `Map` data structure, and that's a pretty neat immutable structure and is usually fine for most stuff, but when performance becomes critical, it's easy enough to break into…
There are basically two points to programming with immutable-first data. One, eliminate certain classes of data race concurrency bugs. Two, less mutable state in a given context makes it easier to reason about.
So, if you're inside a function scope and you aren't launching any concurrent operations from inside that function, you don't have to worry about benefit #1. If you're inside a function (and you're not reaching out for global mutable state), then the context you need to keep in your working memory is likely fairly small, so a few local mutable variables doesn't significantly harm "understandability" of the implementation (in most cases). So, you really don't have to worry about #2, either. Make your functions black boxes with solid "APIs" (type signatures), and let the inside do whatever it needs to make it work the best.
Just because premature optimization is the root of all evil, it doesn't mean we need to jump right to premature pessimization...
Re: I built a Game Boy emulator in F#
#19Sorry for the tangent - does anyone have some really zoomed in views of GB, GBColor, GBA screens in operation? I'd love for retro shaders to be able to more faithfully reproduce. I mean, ideally, we'd run different color test patterns through, in different lighting conditions, to build a really detailed model, right?
I guess buying the second hand devices wouldnt be that expensive.
I've been going through a lot of very old stuff recently and a lot of it is well preserved in a way but given enough years everything changes.
I don't think any original Gameboys have been made in twenty years or more.
Re: I built a Game Boy emulator in F#
#20mildy related but wasn't there an emulator (maybe not GB but NES or SNES?) which had a visual panel showing each CPU cycle step by step? afaik it was very slow but the 1000% accuracy was the goal not playability.