TIC-80 icon indicating copy to clipboard operation
TIC-80 copied to clipboard

WASM runtime memory methods cannot access all RAM

Open joshgoebel opened this issue 2 years ago • 0 comments

That does raise another question though, why do any of the templates use TIC-80's memcpy and memset? Implementing them natively in the source language should allow them to access the full 256 KB of memory used in WASM mode, but the TIC-80 versions appear to be limited to the 96 KB in tic_ram. The only reason I can see is possibly performance, since I would guess that the native C versions are faster than anything that runs in the WASM interpreter.

Originally posted by @soxfox42 in https://github.com/nesbox/TIC-80/issues/1784#issuecomment-1151771461


I've confirmed from reading source that this seems to be correct. The memory size can't be assumed to be 96kb anymore. It's 96kb on scripting runtimes and 256kb on the WASM runtime.

Right now source seems to be using sizeof(tic_ram) which is only going to count the 96kb of built-in RAM I think...

This is probably something that needs to be setup once (at runtime startup - or perhaps it's a static value inside each config) so that it's fast to access... anyways we need a way to access it when all we're given is a *tic_mem pointer, like in most API calls.

joshgoebel avatar Jun 14 '22 09:06 joshgoebel