Playdate games in Rust

Oh! I had only used the PDX file version! I’m not an engineer so I rely on compiled apps :playdate_wink:

I made some changes to selection. I’ll upload a new version as soon as I can so you can see.

Ok this isn’t exactly soon but here it is (81.2 KB).

I made a solver that works so I know the seed I’ve picked is winnable.

I’m kinda warming to @louie’s suggestion on the D-Pad. I could then use the crank backwards for undo and forwards for auto-play to the foundation, maybe.

I’m going to pause Klondike for a bit and work on some basics of the crankstart crate that I’ve decided should change.

Thanks for sharing. Plays pretty nicely/simply.

Also, if it’s helpful for others, when I first unzipped the file, stuffit expander broke it out into separate files and a folder. (Keka did the same until I updated it. after update ok) Simulator could not deal with that format. Apple’s built in Archive Manager just broke it out into the pdx file (as did updated keka), which opened fine in Simulator. I’m not sure about other unarchivers, but figured that I’d share this.

Stuffit Expander, that’s a name I’ve not heard in a long time… #obiwan.

It’s not important, but I’m curious if you use Apple’s Archive Manager to compress a .pdx file, does Stuffit Expander do the right thing with the resulting .zip file?

It should expand ok with any. Looking at stuffit’s site, I see that it hasn’t been supported since 10.11. So, I should have deleted it from the system already. Gone it is.

1 Like

Finally got my device and have been playing this. Sadly, I’m getting a crash every time I make some decent progress dropping cards where they go at the top. It’s never the same card but it’s usually pretty early-- after I get multiple suits up to the 2-4 range. Otherwise, really enjoying playing despite the game’s attempt to keep me from winning! The sprites are crystal clear and look fantastic on the real screen.

Also, I downloaded your zip and I had to extract it into a new folder that I renamed to Klondike.pdx. Not a big deal but just something of note.

Anyways, well done!

The farthest I got after playing this evening:

sadly this is where it crashed again.

1 Like

Huh, I haven’t gotten that far, but I haven’t seen a crash in the version I uploaded a few days ago. Was it when you had a jack in hand and trying to drop it on a pile in the foundation?

It was when I dropped the 10. But it happens regardless of crank use or dock/undock. It’s been very consistent in that it only crashes when I drop a card up top. Just the pattern/time is inconsistent, and the crash log on the device doesn’t contain any information (tried to look for it but found nothing so I didn’t include it). I’ll try again tonight while connected to the pc so I can see if anything comes up in the console.

Hmm it might be how it decides where to put the hand after the drop. I will inspect that code a bit.

Pd (115.8 KB)

Warning, this application hangs on the device.

That’s weird. The entry point (first 4 bytes of the pdex.bin file) is 0x60021e35, but that’s past the end of the file (0x60000000 + 0x1435c). I get a similar error running the pdex.dylib in the simulator: /Users/dave/Downloads/Playground.pdx/pdex.dylib: truncated mach-o error: segment __TEXT extends to 385024 which is past end of file 104953

I wonder if the zipping or unzipping isn’t working? I’ve not had a problem with the dylib on the Mac.

Here’s what the downloaded zip looks like:

Dave:Downloads dave$ unzip -vl Pd\ 
Archive:  Pd
 Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
--------  ------  ------- ---- ---------- ----- --------  ----
  104953  Defl:N    51954  51% 07-22-2020 13:40 ef47c571  pdex.dylib
       0  Stored        0   0% 07-22-2020 13:40 00000000  sprites/
     139  Defl:N      113  19% 07-22-2020 13:40 8e12dbf4  pdxinfo
   82780  Defl:N    53204  36% 07-22-2020 13:40 4edeb8e4  pdex.bin
    6799  Defl:N      715  90% 07-22-2020 13:40 a13203f9  sprites/Sprites.json
   16491  Defl:N     1325  92% 07-22-2020 13:40 3f490b75  sprites/island-1.json
   10370  Defl:N      881  92% 07-22-2020 13:40 2c514be2  sprites/island-1-home.json
     707  Defl:N      348  51% 07-22-2020 13:40 de8781a2  sprites/island-test.json
     886  Defl:N      188  79% 07-22-2020 13:40 86baf240  sprites/
   15763  Defl:N     1266  92% 07-22-2020 13:40 d15a8708  sprites/island-2-dungeon.json
   11361  Defl:N      928  92% 07-22-2020 13:40 99c0f9e0  sprites/island-1-home-basement.json
   54821  Defl:N     2569  95% 07-22-2020 13:40 e967095f  sprites/island-2.json
    2798  Defl:N     2803  -0% 07-22-2020 13:40 300bb7f5  sprites/sprites.pdt
     693  Defl:N      698  -1% 07-22-2020 13:40 c4412fb6  sprites/player.pdt
--------          -------  ---                            -------
  308561           116992  62%                            14 files

Huh, there’s something wrong with the way my crank tool is making the archive. Please try this one, which I compressed with the Finder.

Pd (432.0 KB)

It turns out the Rust library I was using to create zip archives from entire directories had a bug.

Still doesn’t explain what’s going on in the ARM release builds, but I can file a bug with the Rust team about that once the SDK is public and I can give them a reproducible case.

I found a couple of places where unchecked array accesses were causing crashes. With this version I was able to win a game.

winner (80.1 KB) !


The 1.0 SDK made a lot of changes to the C API. I’ve set up a github issue to see if there enough interest in writing PlayDate games in Rust to warrant updating the crate to the 1.0 C API. Please add comments there if you’re someone who would like to see Crankstart updated.

1 Like

Hi Rob, hope this finds you well!

There has been a little talk about Rust on the Discord recently.

Just to get a handle on this, did only break with 1.0 or were there other issues (@dave mentioned stack space on device perhaps being a problem?)

GitHub - rtsuk/crankstart at sdk_1_0_8 brings the Rust bindings up to date with your latest SDK. I haven’t tested recently, but when I did some of the 1.0 adaptation I think I had most everything working.

Stack size is a bit of an issue, it would be great if a binary could request a larger one. 8k is pretty small for a 4MB device. The old Macs used to just have stack grow up and heap grown down and if they met, well, sad Mac.

Your recent announcement video has generated a lot of interest among a decent number of Rust developers, so once the SDK is publicly available I’ll finish up the bindings.