mirror of
https://github.com/kichikuou/xsystem35-sdl2.git
synced 2026-09-22 22:48:08 +03:00
Store ALD files in emscripten heap
For efficient mmap().
This commit is contained in:
+5
-2
@@ -34,8 +34,11 @@ class ImageLoader {
|
||||
private populateFiles(files:any, volumeLabel:string) {
|
||||
var grGenerator = new GameResourceGenerator();
|
||||
for (var name in files) {
|
||||
var data: ArrayBufferView = new Uint8Array(files[name]);
|
||||
FS.writeFile(name, data, { encoding: 'binary' });
|
||||
var data: ArrayBuffer = files[name];
|
||||
// Store contents in the emscripten heap, so that it can be mmap-ed without copying
|
||||
var ptr = Module.getMemory(data.byteLength);
|
||||
Module.HEAPU8.set(new Uint8Array(data), ptr);
|
||||
FS.writeFile(name, Module.HEAPU8.subarray(ptr, ptr + data.byteLength), { encoding: 'binary', canOwn: true });
|
||||
grGenerator.addFile(name);
|
||||
}
|
||||
FS.writeFile('xsystem35.gr', grGenerator.generate());
|
||||
|
||||
+2
-1
@@ -12,10 +12,11 @@ declare namespace Module {
|
||||
function setStatus(status: string): void;
|
||||
function monitorRunDependencies(left: number): void;
|
||||
function callMain(): void;
|
||||
function getMemory(size: number): number;
|
||||
}
|
||||
|
||||
declare namespace FS {
|
||||
function writeFile(path: string, data: ArrayBufferView | string, opts?: {encoding?: string; flags?: string}): void;
|
||||
function writeFile(path: string, data: ArrayBufferView | string, opts?: {encoding?: string; flags?: string; canOwn?: boolean}): void;
|
||||
}
|
||||
|
||||
namespace xsystem35 {
|
||||
|
||||
Reference in New Issue
Block a user