Sorry for the slow down in progress/updates, work was busy for a while and then more recently I got somewhat addicted to speed profiling the new ChakraCore version of miniSphere, hopefully will get back on track with this now.
One key update today - courtesy of ChakraCore - I can now load rmp files and rss files significantly faster by loading the image data as Uint32Arrays and adjusting it into the right layout (tiles into layers, frames into spritesheets) by manipulating those Uint32Arrays without needing to use any graphics functions - this is a significant change to my previous method where everything was drawn onto surfaces with render functions to load it. (I note that the plan is to put these steps into a cellscript anyway which will reduce the relevance of the time they take - but the old method couldn't go in cell as Shapes/Shaders/Textures and Surfaces aren't available in cell - whereas this method can go into cell)
Uint32Arrays are used because I believe they provide the most efficient way to move 4 bytes arund at a time,
The two key functions for this new way of doing it are:
//convert a Uint32Array comprised of tile data where the tiles are written sequentially into an image
function tileBufferToTexture(buffer, t_width, t_height, width, height)
{
var length = t_width * t_height * width * height;
var output = new Uint32Array(length);
for(var i = 0, x = 0, y = 0, t_x = 0, t_y = 0, c = 0, j = 0; i < length; ++i)
{
x = i % t_width
y = Math.floor(i / t_width) % t_height;
t_x = Math.floor(i / (t_height * t_width)) % width;
t_y = Math.floor(i / (t_width * t_height * width));
j = (x + y * t_width * width + t_x * t_width + t_y * (t_width * t_height * width));
output[j] = buffer[i]
}
return new Texture(width * t_width, height * t_height, output);
}
//write tile to position target in m_buffer
function setTileInBuffer(t_buffer, m_buffer, t_width, t_height, tile, target)
{
var t_size = t_width * t_height;
var m_start = t_size * target;
var t_start = t_size * tile;
//note uses a loop for moving the data rather than set and slice intentionally
//due to large number of times this is called set and slice incur a larger overhead
//due to related memory management issues
for(var i = 0; i < t_size; ++ i)
{
m_buffer[m_start + i] = t_buffer[t_start + i];
}
}