These are some advanced optimization tricks I've discovered while @stonerl and I have been cooking the full-speed gameboy emulator. These are not the typical tips for optimizing games you can find elsewhere, so if you…
14 comments
The quirks of that console for this is that the CPU takes a 6 cycle stall on any read from main RAM (it's not even stall-on-use) and doesn't have a data cache. That would make it a very poor fit for this, so I had to improvise a bunch of tricks to reclaim performance:
- Made all of my hot loop fit within one function, so that it fits entirely in the 4 KiB direct-mapped instruction cache (so less than 1024 instructions)
- Wrote a C++ template that can trampoline a function call into the 2 KiB scratchpad
- Used the rest of the scratchpad for a CLUT table because it doesn't stall on read
- Used the GTE to transform the N set of coordinates while the CPU stalls fetching the N+1 set of heightmap data
- Figured ways to abuse the GTE into transforming more points per instructions than it theoretically can, taking advantage of simplified formulas compared to real 3D projection
- Write the rectangle primitives straight to the GPU registers instead of going through a display list
It's such an abuse of the PlayStation that PCSX-Redux and DuckStation disagree on its performance by up to a factor of two. I should finish it someday and see how it runs on real hardware...
(If you are the kind of person that finds optimizations fun, of course. There is a puzzle solving element of optimizing code that I really enjoy.)
I haven't looked into how that all nets out, but when I think about how much a Raspberry Pi costs by itself vs the Pi + a case, screen, and peripherals... I don't know, I can see how you'd end up around $230.
Heck, even just a set of Switch 2 Joycons costs $100.
So it is beyond obvious that Playdate's price does not even closely match their bill of materials.
Even if you went up in power to a full Linux machine with 1GB+ of ram, there are obvious examples of devices like that like the RG3588 class. I have one, and it works nicely as a linux box running any software one can get running on aarch64 linux. Mine is relatively fancy and with postage cost me ~100$, but you can get a more "basic" one that is still way beyond Playdate on a hardware level, for about 40$.
What playdate has is a walled garden. I don't like walled gardens. Especially this far from release.
You comparing to Nintendo's first-party joycon pricing, I'm not sure you understand how deep walled gardens can be.
Read the full thread on Hacker News →
Related stories
- Dirty Optimization Secrets (C for Playdate)devforum.play.dateHacker News · 1 points · about 2 months ago
- Dirty Optimization Secrets (C for Playdate)devforum.play.dateLobsters · 28 points · about 2 months ago
- Hacker News · 2 points · 2 months ago
- Hacker News · 1 points · 2 months ago
- Recursive Cognitive Optimization (RCO)github.comHacker News · 1 points · 2 months ago
- How Secrets Work in Dockerinfisical.comHacker News · 3 points · 2 months ago