SDL2 drivers for Playdate? Yes!

There is not an issue anymore. It can hit memory limits if the games are sloppily ported.

1 Like

So it sounds like SDL2 can be used to make truly portable games as long as the Cortex M7+16MB RAM is sufficient to run them. From an architectural standpoint, could it make sense to just use color graphics and let SDL crunch to 1-bit and do the dithering? (Obviously, custom 1-bit graphics will almost certainly give crisper results.)

I will provide hints to control dithering eventually.

you do just use color graphics. it is automatically dithered and rendered directly to the framebuffer.

The upstream draft lists threads as the ideal solution for handling SDL2 audio. C API threading support for Playdate is inconclusive, but pthread may be available. It sounds like someone would need to make a test project to find out.

pthreads aren’t supported. neither is memory management, high resolution clocks, etc. it might be possible to implement those in some way however. At this point I’ve got a micro kernel on my hands lol.

Looks like the official word is that threads are not supported. Regarding memory management, you can always do the equivalent of malloc()ing the entire heap. Then memory can be handed out as you see fit.

you can always do the equivalent of malloc() ing the entire heap

SDL has implementations of some significant parts of the C runtime built in, for systems where the C runtime isn't available or trustworthy. One of these things is an implementation of malloc() that can operate out of a preallocated block of memory...so SDL_malloc() and friends can work as expected even if the system just says "you can use this block of the address space and that's it."

1 Like

(just as a heads up, I'll likely do technical discussion on the pull request page, so if I don't reply here, it's just because I live and die by my GitHub notifications nowadays.)

1 Like

Yep! Also, PD does support malloc etc if you setup correctly. I was just using that as an example @sgeos :smiley:

Also, totally understood on the discussion thing. Now that the process has begun it is better we do all discussing there!

I am not convinced this actually belongs in the PR, so I am going to put it here.

When it comes to audio, what sort of workflow is the composer/arranger going to be looking at? Does it make sense for work to be done in something like Cubase before a final playback file is exported?

Playdate has generative audio capabilities. Has anyone written a portable generative audio package that works with SDL2? Implicit in this question is that such a package needs to be able to run on the Playdate too.

I can’t really speak well to your first question (I think it depends, but if you are targeting playdate you should be keeping its limitations in mind)

As for the second question: probably. You can mess with the audio buffer directly. As for exposing the underlying synth apis for play date… there isn’t anything to gain. SDL2 is an abstraction layer and in this case I think the abstraction is mostly around simple audio manipulation (which can be augmented).

SDL2 will handle audio conversion into whatever format works best in the driver. That said; ideally the developer keeps these limitations in mind and doesn’t stress the system too much. You can also still totally interact with the system directly. I’ve seen plenty of apps that don’t bother using the SDL file api and instead going straight to fd.

When you need it, you go bare metal. Even all major video games have a little non-portable code in them.

The goal is to keep as much portable as possible. That makes the project easier to manage.

There are two problems here- runtime playback, and file size. MP3 should be fine for runtime playback because it is premixed, but a lot of music will bloat the size of the final executable. The Playdate documentation mentions that generative audio can keep file sizes down. That is great, but I want portable generative audio so my game can be run on different platforms.

After SDL2 has been ported, do you have plans to port SDL_mixer? It has dependencies, and I have no idea what implications are for file size and porting-related headaches.

Finally, it seems like mixing 1 BGM and 2 SFX ought to be a reasonable load.

Portability isn’t the only benefit. Familiarity with the API surface is another big plus. I.e I makes games and don’t need to learn exactly how the apis work on Playdate to make a game.

The way audio works with SDL2 the only real option is play the raw buffer data. How it gets to the driver isn’t something SDL cares about.

Hi, dev of m4kc here. The reason it's running out of memory is not because of the textures - its definitely the world size. Currently the world is split up into 27 chunks which each have 64x64x64 blocks, and each block ID is stored as an int. This works out to hundreds of megabytes of memory needed for just block data. In order to get this to run on lower end hardware, the world size would need to be decreased.

At some point I am probably going to change the data type the blocks are stored in to an unsigned 8 bit integer, which would be much more memory efficient.

Did not expect this little project of mine to make its way outside github, pretty cool what you all are doing here :slight_smile:

Update: Just pushed a commit switching block IDs to u_int8_t. This nearly quarters memory usage.

2 Likes

Oh wow! I did not expect to see you here either! I also made quite a number of other changes to move the game loop out & add controller support. I would love to keep trying to get this to run!

I had attempted to make the world very small and somewhat succeeded also dropped menus etc. But no dice. Thanks for coming over here!

oh and I forgot to mention- I got heap allocation below 16mb, it's the stack that blows on us.

1 Like

Hmmm... that's odd, to my knowledge there aren't any large blocks of data allocated on the stack other than the textures, but that's only around 300 kilobytes of data. (Apparently global variables don't go on the stack). I'll probably have to look deeper into this.

1 Like

Has SDL2 for Playdate stalled, or is it moving forward?

1 Like

Quite busy with other things at the moment, but do finally have my hardware.

4 Likes

How are things on this? I have a game engine that uses SDL and I came across this and got excited!

1 Like