Ah. By that metric it’s going to update the entire screen every-time. This isn’t e-ink. The entire screen is reloaded for every frame regardless of what you got going on computationally underneath. (At least I assume, it's possible panic made the process row by row and my HTML canvas comparison doesn't exactly work here since HTML Canvases also have the outside OS screen rendering to worry about and you can't really "chase the buffer").
Instead you should think of updating dirty regions of draw as more like updating sections of memory for that process. In practice this plays out more like animating a scene using ms paint where you either recreate the entire thing screen by screen every-time, or you just make all the small changes to the regions of the image as required frame by frame.
In 3D graphics, moving the camera effects the entire screen so usually you are doing the math at the entire screen level anyway (there’s the possibility of using motion vectors though to change the math to difference between previous and next frame though which effectively is closer to the concept of dirty draw).
The complicated part of dirty draw though (based on my experience with canvas drawing) is that you need the drawing process to be reversible.
Ie: if I point to a region on the screen I want to redraw while ignoring touching the rest…., you need to know what parts of the code only affect that region you are trying to redraw and rerun the drawing process for just this region.
This is easier with sprites and background images because (assuming no rotations or moving background) the math is more like: grab this subregion of this image and copy the memory over here rather than copy the memory of the whole thing.
Not so easy with code generated stuff which isn’t going to have fixed sizes and positioning. Not to say it isn’t worth it though in some cases.
In the case of the rain though which takes over so much of the screen with so many small parts, the process of jumping around the memory to copy this small piece and that small piece is likely to be heavier than just copying the whole thing without trying to subdivide. Maybe motion vectors could work here to process things in a quickly iterable way, but at that point you are usually better breaking down rendering into slow processes taking multiple frames and letting quicker motion vectors to handle the in between but that’s both really complicated and likely to make the “response to human input” portion of the code slower (basically allowing you to work ahead for the next 2-3 frames as you aren't concerning yourself with the random noise generators that are humans).
Oh, and this should go without saying but motion vectors + the hardware in place/level of math going on behind the scenes could be wholly not worth it what-so-ever. I just mention it as I understand it from the VR world.
Playdate screen (Sharp Memory LCD) is actually quite like eink: rows that aren't updated retain their display and use almost no power.
Playdate SDK Sprite system allows you to do partial redraw/refresh. Of course it only works with some game designs. It won't work for your rain.
I recommend taking a look at the SDK Examples, make sure to turn on "Highlight Screen Updates" in the Simulator, and immerse yourself in the docs to learn more about this.
Interested in using nim and these nimble bindings for Playdate and have followed the installation instructions for Windows (I'm on Windows 11). However I'm unable to build the 'playdate_example' included in the git repo. I'm having this error:
playdate_example\src\playdate_example.nim(22, 38) Error: attempting to call undeclared routine: 'getButtonState'
Is this a known issue? I'm using Playdate SDK 2.4.2, should I roll back to an earlier version of the Playdate SDK? I didn't see a recommended Playdate SDK version on the Playdate Nim readme, but I assume something has changed in the more recent SDK's?
This is due to the published package (v0.13.0) not being up to date with the main branch of the repo.
v0.14.0 will be released soon, but in the meantime you can rename getButtonState to getButtonsState
I had other issues, so I simply replaced the playdate 0.13.0 package contents with the latest in the repo which solved all those, but now it seems my mingw64 setup isn't quite correct.
Ugh Windows. Time to escape to the Linux laptop I have and try again...
Are folks generally using nim playdate under Linux or Windows?
I float around a bunch of platforms and tooling and honestly...things just always seem to work better under the original platform they were built on.
I agree things should work under Windows...but in may case I just want to code games Moving to Linux and things are already working better. I acknowledge this is a somewhat selfish and non-altruistic stance!
Edit: Ah @jmation I see your post above and have just tried that as well. Let's see if it builds now...? Hmmmm no still have issues. Might have to reboot...
This was one of multiple issues I had on Windows. Note the path it searches for the compiler.
That's mingw64 inside the nim installation folder.
The windows builds of Nim try to help you out by bundling mingw64, but that does not contain the compiler for playdate. The stupid thing is that if you install a separate compiler, it won't find it.
What I did:
remove Nim installation. I believe it's just a matter of deleting the folder
download choosenim and use it to install nim.
This will get you nim without the bundled mingw64.
now make sure your msys2 mingw installation is in working order, with it's bin folder on the path.
My recommendation is to start with the example project instead of creating a new nim project. There are some configurations in place in the sample project that you can benefit from. It's also simply a good sanity check to see if your environment is in working order.
OK, one more gotcha: make sure the playdate sdk is up to date. I think 2.4.0 is the minimum. But really, just make sure you keep it up to date.
(can you tell I got burned by this one? )
Haha thanks for the tips! Yes my Windows machine is a mixed bag of installed toolkits.
I will try these suggestions on Windows because I am very curious to try nim on play.date. I'm a crusty C programmer but haven't used it in anger for decades. Nim seemed like a much nicer solution, if only I could get it working :).
I can definitely build the Play.date C Examples without issue under Windows so yes likely some nim tool chain oddities.
This is probably a stupid question but I’m wondering if anyone knows how to fix a linting/error checking issue I’m having in vscode. I want to use the latest bindings on GitHub but when I copy the files over the previous installed version the error checking stops working. Everything else works fine.
Installed playdate sdk using nimble in vscode - 0.13 version (all worked great) - C:\Users\pc.nimble\pkgs\playdate-0.13.0
I then copied the latest files from GitHub over the top (basic copy paste)
Everything still works but the linting/error checking stopped working
Not sure how I fix this, any clues? Or is there a way to install so the linting knows where to look?
What you're addressing is something I was concerned with... "to ucrt or not to ucrt". This is just another layer of uncertainty of how playdate, playdate-nim and the simulator need to function together. My first confusion was the install of mingw via Nim, and then to find out about needing the toolchain for ARM, which was to be found from a different source. I also had a version of Nim not supported by playdate-nim. I uninstalled everything, then installed choosenim to install Nim. Now on to this MSYS needs. Thanks!
Windows Simulate builds using Msys2 ucrt:
pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain
The build for the device issues the below warnings but on a second build doesn't because it is in the nimcache, not sure if this is something to be worried about, it might have done this before and I just didn't notice? Other than that the example file works great.
PS C:\Users\James\Downloads\playdate-nim-main\playdate-nim-main\playdate_example> nimble device --verbose
Info: Nimble data file "C:\Users\James.nimble\nimbledata2.json" has been loaded.
Verifying dependencies for playdate_example@0.8.0
Reading official package list
Checking for playdate@any version
Info: Dependency on playdate@any version already satisfied
Verifying dependencies for playdate@0.21.0
Executing task device in C:\Users\James\Downloads\playdate-nim-main\playdate-nim-main\playdate_example\playdate_example.nimble
Info: Nimble data file "C:\Users\James.nimble\nimbledata2.json" has been loaded.
Verifying dependencies for playdate_example@0.8.0
Reading official package list
Checking for playdate@any version
Info: Dependency on playdate@any version already satisfied
Verifying dependencies for playdate@0.21.0
Building playdate_example/playdate_example.exe using c backend
Executing C:\Users\James.nimble\bin\nim.exe c --colors:on --noNimblePath -d:device -d:release -d:NimblePkgVersion=0.8.0 --path:C:\Users\James\Downloads\playdate-nim-main\playdate-nim-main\src -o:C:\Users\James\Downloads\playdate-nim-main\playdate-nim-main\playdate_example\playdate_example.exe C:\Users\James\Downloads\playdate-nim-main\playdate-nim-main\playdate_example\src\playdate_example.nim
Setting os to any
Hint: used config file 'C:\Users\James.choosenim\toolchains\nim-2.0.0\config\nim.cfg' [Conf]
Hint: used config file 'C:\Users\James.choosenim\toolchains\nim-2.0.0\config\config.nims' [Conf]
Hint: used config file 'C:\Users\James\Downloads\playdate-nim-main\playdate-nim-main\playdate_example\config.nims' [Conf]
.......................................................................................................................
CC: setup
CC: ../../../../../.choosenim/toolchains/nim-2.0.0/lib/system/exceptions.nim
CC: ../../../../../.choosenim/toolchains/nim-2.0.0/lib/std/private/digitsutils.nim
CC: ../../../../../.choosenim/toolchains/nim-2.0.0/lib/std/formatfloat.nim
CC: ../../../../../.choosenim/toolchains/nim-2.0.0/lib/system/dollars.nim
CC: ../../src/playdate/bindings/memtrace.nim
CC: ../../../../../.choosenim/toolchains/nim-2.0.0/lib/system/repr_v2.nim
CC: ../../../../../.choosenim/toolchains/nim-2.0.0/lib/system.nim
CC: ../../src/playdate/bindings/graphics.nim
CC: ../../src/playdate/bindings/system.nim
CC: ../../src/playdate/bindings/file.nim
CC: ../../src/playdate/bindings/display.nim
CC: ../../src/playdate/bindings/api.nim
CC: ../../../../../.choosenim/toolchains/nim-2.0.0/lib/pure/parseutils.nim
CC: ../../../../../.choosenim/toolchains/nim-2.0.0/lib/pure/unicode.nim
CC: ../../../../../.choosenim/toolchains/nim-2.0.0/lib/pure/math.nim
CC: ../../../../../.choosenim/toolchains/nim-2.0.0/lib/pure/strutils.nim
CC: ../../../../../.choosenim/toolchains/nim-2.0.0/lib/pure/strformat.nim
CC: ../../../../../.choosenim/toolchains/nim-2.0.0/lib/pure/random.nim
CC: ../../src/playdate/system.nim
CC: ../../src/playdate/graphics.nim
CC: ../../src/playdate/file.nim
CC: ../../../../../.choosenim/toolchains/nim-2.0.0/lib/pure/collections/lists.nim
CC: ../../src/playdate/types.nim
CC: ../../src/playdate/sprite.nim
CC: ../../src/playdate/sound.nim
CC: ../../src/playdate/scoreboards.nim
CC: ../../../../../.choosenim/toolchains/nim-2.0.0/lib/pure/hashes.nim
CC: ../../../../../.choosenim/toolchains/nim-2.0.0/lib/pure/collections/tables.nim
CC: ../../../../../.choosenim/toolchains/nim-2.0.0/lib/pure/streams.nim
CC: ../../../../../.choosenim/toolchains/nim-2.0.0/lib/pure/lexbase.nim
CC: ../../../../../.choosenim/toolchains/nim-2.0.0/lib/pure/parsejson.nim
C:\Users\James\nimcache\playdate_example_r\device@m..@s..@ssrc@splaydate@ssystem.nim.c: In function 'addCheckmarkMenuItem__OOZOOZsrcZplaydateZsystem_u821':
C:\Users\James\nimcache\playdate_example_r\device@m..@s..@ssrc@splaydate@ssystem.nim.c:355:87: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
355 | add__OOZOOZsrcZplaydateZsystem_u776((&menuItems__OOZOOZsrcZplaydateZsystem_u481), (((tyObject_PDMenuItemcolonObjectType___3r7ocxs6y5jhOny48GeCxw**) (&(colontmpD__3)))));
| ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CC: ../../../../../.choosenim/toolchains/nim-2.0.0/lib/pure/json.nim
CC: ../../src/playdate/api.nim
CC: playdate_example.nim
C:\Users\James\nimcache\playdate_example_r\device@m..@s..@s..@s..@s..@s.choosenim@stoolchains@snim-2.0.0@slib@spure@sstreams.nim.c: In function 'ssClose__pureZstreams_u891':
C:\Users\James\nimcache\playdate_example_r\device@m..@s..@s..@s..@s..@s.choosenim@stoolchains@snim-2.0.0@slib@spure@sstreams.nim.c:285:11: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
285 | s_2 = (((tyObject_StringStreamObj__2VWq9a8gmGbkj9bGsucBK1ag**) (&(colontmpD_))));
| ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\James\nimcache\playdate_example_r\device@m..@s..@s..@s..@s..@s.choosenim@stoolchains@snim-2.0.0@slib@spure@sstreams.nim.c: In function 'ssSetPosition__pureZstreams_u793':
C:\Users\James\nimcache\playdate_example_r\device@m..@s..@s..@s..@s..@s.choosenim@stoolchains@snim-2.0.0@slib@spure@sstreams.nim.c:310:11: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
310 | s_2 = (((tyObject_StringStreamObj__2VWq9a8gmGbkj9bGsucBK1ag**) (&(colontmpD_))));
| ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\James\nimcache\playdate_example_r\device@m..@s..@s..@s..@s..@s.choosenim@stoolchains@snim-2.0.0@slib@spure@sstreams.nim.c: In function 'ssReadDataStr__pureZstreams_u807':
C:\Users\James\nimcache\playdate_example_r\device@m..@s..@s..@s..@s..@s.choosenim@stoolchains@snim-2.0.0@slib@spure@sstreams.nim.c:345:11: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
345 | s_2 = (((tyObject_StringStreamObj__2VWq9a8gmGbkj9bGsucBK1ag**) (&(colontmpD_))));
| ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\James\nimcache\playdate_example_r\device@m..@s..@s..@s..@s..@s.choosenim@stoolchains@snim-2.0.0@slib@spure@sstreams.nim.c: In function 'ssReadData__pureZstreams_u864':
C:\Users\James\nimcache\playdate_example_r\device@m..@s..@s..@s..@s..@s.choosenim@stoolchains@snim-2.0.0@slib@spure@sstreams.nim.c:376:11: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
376 | s_2 = (((tyObject_StringStreamObj__2VWq9a8gmGbkj9bGsucBK1ag**) (&(colontmpD_))));
| ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\James\nimcache\playdate_example_r\device@m..@s..@s..@s..@s..@s.choosenim@stoolchains@snim-2.0.0@slib@spure@sstreams.nim.c: In function 'ssWriteData__pureZstreams_u881':
C:\Users\James\nimcache\playdate_example_r\device@m..@s..@s..@s..@s..@s.choosenim@stoolchains@snim-2.0.0@slib@spure@sstreams.nim.c:422:11: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
422 | s_2 = (((tyObject_StringStreamObj__2VWq9a8gmGbkj9bGsucBK1ag**) (&(colontmpD_))));
| ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\James\nimcache\playdate_example_r\device@m..@s..@s..@s..@s..@s.choosenim@stoolchains@snim-2.0.0@slib@spure@sjson.nim.c: In function 'parseJson__pureZjson_u5846':
C:\Users\James\nimcache\playdate_example_r\device@m..@s..@s..@s..@s..@s.choosenim@stoolchains@snim-2.0.0@slib@spure@sjson.nim.c:2285:41: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
2285 | result = parseJson__pureZjson_u5839((*((tyObject_StreamObj__hNmHk9a6m386ZI9c8umyup7g**) (&(colontmpD__2)))), TM__9b9bytt1stv9cZ8uqII7HFgew_64, rawIntegers_p1, rawFloats_p2);
| ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Hint: [Link]
Hint: mm: arc; opt: none (DEBUG BUILD, -d:release generates faster code); options: -d:release
91787 lines; 1.691s; 137.66MiB peakmem; proj: C:\Users\James\Downloads\playdate-nim-main\playdate-nim-main\playdate_example\src\playdate_example.nim; out: C:\Users\James\Downloads\playdate-nim-main\playdate-nim-main\playdate_example\playdate_example.exe [SuccessX]
Info: Nimble data file "C:\Users\James.nimble\nimbledata2.json" has been saved.
pdc version:
2.6.2
Unrecognized file types are copied by default. Use the -k or --skip-unknown flag to skip these files instead.
Copying json/data.json
Copying json/error.json
Info: Nimble data file "C:\Users\James.nimble\nimbledata2.json" has been saved.
PS C:\Users\James\Downloads\playdate-nim-main\playdate-nim-main\playdate_example>