- For repeated expensive drawing options, such as drawing a rotated sprite or a large amount of text, it's a good idea to cache the result to an image once and draw that repeatedly instead.
- Audio formats in order of decode speed, fastest to slowest: 16-bit pcm wav, 8-bit pcm wav, adpcm, mp3.
- The Playdate's audio sample rate is 44100, but if you're experiencing lag when playing audio at that rate, you can try halving the rate to 22050.
- The Playdate has a weak CPU but a comparatively generous amount of memory. Favour memory-based optimisation techniques, such as lookup tables.
- Where possible, move branch statements outside of loops, even if it means duplicating the code for the loop. (probably applies to Lua too?)
- If you need to parse a binary file, use playdate->file->seek to jump to the parts you need and playdate->file->read to only read the data you want. Try to avoid memcpy-ing the whole file to memory in one go.
- If you're blitting to the frame buffer and need to apply a pattern, use the bitwise and operator to mask your frame buffer against a premade pattern table. It's also ever so slightly faster to operate on your framebuffer 32 bits at a time, if possible.
- Avoid recursion, you will stack overflow very fast.
- When you compile a device build, a file called
Playnote_DEVICE
will be created in yourbuild
directory. (TODO: check this is the case for all build setups?). This is an ELF file, so you can load it into a decompilation tool like Ghidra to see the low-level instructions that the compiler has generated for your code, and look for potential performance issues there.
- If you import everything your game uses into main.lua, and you're not using playdate.file.load() or playdate.file.run(), it is safe to strip every .pdz file apart from main.pdz from your game's compiled pdx.
- C gets built into different formats depending on if you're targeting the Playdate device or Playdate Simulator. If you don't care for Simulator compatibility, you can strip any .dll, .dylib, etc files from your device build