wasm4
wasm4 copied to clipboard
[feature] Real time
For audio sequence should be provided a timecode. We can use a tick of update, but how i know it depend of RAF frequency, and we can't sync a APU with update for sequencing.
I know that WASM export a seed function that really is Date.now, and this already can be used, but is hacky.
maybe we can provide a time function same way?
UPD, i see that now we use a clamped update, and it should runs about 60 frames on any screens, exclude a iOS in power-save mode (it ticks 30 FPS)
https://github.com/aduros/wasm4/blob/main/runtimes/web/src/index.js#L343
I've wanted this too. Right now both of my games initialize the PRNG with a fixed number, but it would be nice to seed with time. (I don't see the seed described above).
The time could be an imported function, but it might be nice to have it directly in memory too.
Right now both of my games initialize the PRNG with a fixed number
You can count frames and seed it with timing information from the first few buttons presses... most things have a startup sequence (title screen, etc) that allows you to get some entropy from that...
I second that this would be useful though for idle games... so someone could leave the game and come back later and the game would update their progress based on them being gone 2 days, etc...
I'd vote that we minimally have access to "milliseconds* since the Unix Epoch", ie in JS:
new Date().getTime()
(and whatever the equivalent is native...)
What some other consoles are doing:
- https://github.com/nesbox/TIC-80/wiki/tstamp (unix timestamp)
- https://pico-8.fandom.com/wiki/Stat#.7B80.E2.80.A685.2C90.E2.80.A695.7D_Time_of_day (year, month, day, etc...)
so someone could leave the game and come back later and the game would update their progress based on them being gone 2 days, etc...
Somebody has gotta make an Animal Crossing clone for WASM-4!
I had an issue with the inconsistent framerate and missing timing functionality. I tried a hack to mix colors by switching palettes but due to the inconsistent framerate it flickers a lot (even on the simplest example: https://gist.github.com/hrobeers/a72bb460e1ce9be8a2aebed82d66fa91). This flickering can might cool to use for some effects, so maybe the inconsistent framerate should be an official "hardware spec".
In order to be able to mix colors a working timing functionality could help reduce the flickering. As I seem to understand this is a WASI limitation? I have some emscripten projects that use C++ <chrono> without issues.
Great project BTW, I really love the wasm base for a fantasy console!
The frame timing all needs to be done on the "outside" (with the host OS, etc), since your code is only running via callback. There are lots of reasons to add timing, but frame rate consistency isn't one of them.
The frame timing all needs to be done on the "outside" (with the host OS, etc), since your code is only running via callback. There are lots of reasons to add timing, but frame rate consistency isn't one of them.
Oh yes I agree with that. I was hoping to use timing to be able to mix the colors at a lower rate based on time passed but I realize this would be flickering even more. Thanks for your reply.