updated fs65 libraries to Jun 13 2018

seperate filesystems for each cc65 platform
This commit is contained in:
Steven Hugg 2018-06-20 03:09:37 -04:00
parent 2fd40ce383
commit 14665e3cd4
20 changed files with 162552 additions and 27268 deletions

152
presets/apple2/mandel.c Normal file
View File

@ -0,0 +1,152 @@
/*****************************************************************************\
** mandelbrot sample program for cc65. **
** **
** (w) 2002 by groepaz/hitmen, TGI support by Stefan Haubenthal **
\*****************************************************************************/
#include <stdlib.h>
#include <time.h>
#include <conio.h>
#include <tgi.h>
#include <cc65.h>
/* Graphics definitions */
#define SCREEN_X (tgi_getxres())
#define SCREEN_Y (tgi_getyres())
#define MAXCOL (tgi_getcolorcount())
#define maxiterations 32
#define fpshift (10)
#define tofp(_x) ((_x)<<fpshift)
#define fromfp(_x) ((_x)>>fpshift)
#define fpabs(_x) (abs(_x))
#define mulfp(_a,_b) ((((signed long)_a)*(_b))>>fpshift)
#define divfp(_a,_b) ((((signed long)_a)<<fpshift)/(_b))
/* Workaround missing clock stuff */
#ifdef __APPLE2__
# define clock() 0
# define CLK_TCK 1
#endif
/* Use dynamically loaded driver by default */
#ifndef DYN_DRV
# define DYN_DRV 0
#endif
/* Use static local variables for speed */
//#pragma static-locals (1);
void mandelbrot (signed short x1, signed short y1, signed short x2,
signed short y2)
{
register unsigned char count;
register signed short r, r1, i;
register signed short xs, ys, xx, yy;
register signed short x, y;
/* Calc stepwidth */
xs = ((x2 - x1) / (SCREEN_X));
ys = ((y2 - y1) / (SCREEN_Y));
yy = y1;
for (y = 0; y < (SCREEN_Y); y++) {
yy += ys;
xx = x1;
for (x = 0; x < (SCREEN_X); x++) {
xx += xs;
/* Do iterations */
r = 0;
i = 0;
for (count = 0; (count < maxiterations) &&
(fpabs (r) < tofp (2)) && (fpabs (i) < tofp (2));
++count) {
r1 = (mulfp (r, r) - mulfp (i, i)) + xx;
/* i = (mulfp(mulfp(r,i),tofp(2)))+yy; */
i = (((signed long) r * i) >> (fpshift - 1)) + yy;
r = r1;
}
if (count == maxiterations) {
tgi_setcolor (0);
} else {
if (MAXCOL == 2) {
tgi_setcolor (1);
} else {
tgi_setcolor (count % MAXCOL);
}
}
/* Set pixel */
tgi_setpixel (x, y);
}
}
}
int main (void)
{
clock_t t;
unsigned long sec;
unsigned sec10;
unsigned char err;
clrscr ();
#if DYN_DRV
/* Load the graphics driver */
cprintf ("initializing... mompls\r\n");
tgi_load_driver (tgi_stddrv);
#else
/* Install the graphics driver */
tgi_install (a2_lo_tgi);
#endif
err = tgi_geterror ();
if (err != TGI_ERR_OK) {
cprintf ("Error #%d initializing graphics.\r\n%s\r\n",
err, tgi_geterrormsg (err));
if (doesclrscrafterexit ()) {
cgetc ();
}
exit (EXIT_FAILURE);
};
cprintf ("ok.\n\r");
/* Initialize graphics */
tgi_init ();
tgi_clear ();
t = clock ();
/* Calc mandelbrot set */
mandelbrot (tofp (-2), tofp (-2), tofp (2), tofp (2));
t = clock () - t;
/* Fetch the character from the keyboard buffer and discard it */
cgetc ();
/* Shut down gfx mode and return to textmode */
tgi_done ();
/* Calculate stats */
sec = (t * 10) / CLK_TCK;
sec10 = sec % 10;
sec /= 10;
/* Output stats */
cprintf ("time : %lu.%us\n\r", sec, sec10);
if (doesclrscrafterexit ()) {
/* Wait for a key, then end */
cputs ("Press any key when done...\n\r");
cgetc ();
}
/* Done */
return EXIT_SUCCESS;
}

View File

@ -25,8 +25,8 @@
#define COUNT 16384 /* Up to what number? */
#define SQRT_COUNT 128 /* Sqrt of COUNT */
#define COUNT 4096 /* Up to what number? */
#define SQRT_COUNT 64 /* Sqrt of COUNT */
static unsigned char Sieve[COUNT];

4298
presets/apple2/tb_6502.s Normal file

File diff suppressed because it is too large Load Diff

14
presets/apple2/textdemo.s Normal file
View File

@ -0,0 +1,14 @@
.segment "INIT"
.segment "ONCE"
.segment "STARTUP"
.segment "CODE"
Loop:
lda $480,y
clc
adc #1
sta $480,y
iny
bne Loop
jmp Loop

236
presets/apple2/tgidemo.c Normal file
View File

@ -0,0 +1,236 @@
#include <stdio.h>
#include <stdlib.h>
#include <cc65.h>
#include <conio.h>
#include <ctype.h>
#include <modload.h>
#include <tgi.h>
#ifndef DYN_DRV
# define DYN_DRV 0
#endif
#define COLOR_BACK TGI_COLOR_BLACK
#define COLOR_FORE TGI_COLOR_WHITE
/*****************************************************************************/
/* Data */
/*****************************************************************************/
/* Driver stuff */
static unsigned MaxX;
static unsigned MaxY;
static unsigned AspectRatio;
/*****************************************************************************/
/* Code */
/*****************************************************************************/
static void CheckError (const char* S)
{
unsigned char Error = tgi_geterror ();
if (Error != TGI_ERR_OK) {
printf ("%s: %d\n", S, Error);
if (doesclrscrafterexit ()) {
cgetc ();
}
exit (EXIT_FAILURE);
}
}
#if DYN_DRV
static void DoWarning (void)
/* Warn the user that the dynamic TGI driver is needed for this program */
{
printf ("Warning: This program needs the TGI\n"
"driver on disk! Press 'y' if you have\n"
"it - any other key exits.\n");
if (tolower (cgetc ()) != 'y') {
exit (EXIT_SUCCESS);
}
printf ("OK. Please wait patiently...\n");
}
#endif
static void DoCircles (void)
{
static const unsigned char Palette[2] = { TGI_COLOR_WHITE, TGI_COLOR_ORANGE };
unsigned char I;
unsigned char Color = COLOR_FORE;
unsigned X = MaxX / 2;
unsigned Y = MaxY / 2;
tgi_setpalette (Palette);
while (!kbhit ()) {
tgi_setcolor (COLOR_FORE);
tgi_line (0, 0, MaxX, MaxY);
tgi_line (0, MaxY, MaxX, 0);
tgi_setcolor (Color);
for (I = 10; I < 240; I += 10) {
tgi_ellipse (X, Y, I, tgi_imulround (I, AspectRatio));
}
Color = Color == COLOR_FORE ? COLOR_BACK : COLOR_FORE;
}
cgetc ();
tgi_clear ();
}
static void DoCheckerboard (void)
{
static const unsigned char Palette[2] = { TGI_COLOR_WHITE, TGI_COLOR_BLACK };
unsigned X, Y;
unsigned char Color;
tgi_setpalette (Palette);
Color = COLOR_BACK;
while (1) {
for (Y = 0; Y <= MaxY; Y += 10) {
for (X = 0; X <= MaxX; X += 10) {
tgi_setcolor (Color);
tgi_bar (X, Y, X+9, Y+9);
Color = Color == COLOR_FORE ? COLOR_BACK : COLOR_FORE;
if (kbhit ()) {
cgetc ();
tgi_clear ();
return;
}
}
Color = Color == COLOR_FORE ? COLOR_BACK : COLOR_FORE;
}
Color = Color == COLOR_FORE ? COLOR_BACK : COLOR_FORE;
}
}
static void DoDiagram (void)
{
static const unsigned char Palette[2] = { TGI_COLOR_WHITE, TGI_COLOR_BLACK };
int XOrigin, YOrigin;
int Amp;
int X, Y;
unsigned I;
tgi_setpalette (Palette);
tgi_setcolor (COLOR_FORE);
/* Determine zero and aplitude */
YOrigin = MaxY / 2;
XOrigin = 10;
Amp = (MaxY - 19) / 2;
/* Y axis */
tgi_line (XOrigin, 10, XOrigin, MaxY-10);
tgi_line (XOrigin-2, 12, XOrigin, 10);
tgi_lineto (XOrigin+2, 12);
/* X axis */
tgi_line (XOrigin, YOrigin, MaxX-10, YOrigin);
tgi_line (MaxX-12, YOrigin-2, MaxX-10, YOrigin);
tgi_lineto (MaxX-12, YOrigin+2);
/* Sine */
tgi_gotoxy (XOrigin, YOrigin);
for (I = 0; I <= 360; I += 5) {
/* Calculate the next points */
X = (int) (((long) (MaxX - 19) * I) / 360);
Y = (int) (((long) Amp * -cc65_sin (I)) / 256);
/* Draw the line */
tgi_lineto (XOrigin + X, YOrigin + Y);
}
cgetc ();
tgi_clear ();
}
static void DoLines (void)
{
static const unsigned char Palette[2] = { TGI_COLOR_WHITE, TGI_COLOR_BLACK };
unsigned X;
tgi_setpalette (Palette);
tgi_setcolor (COLOR_FORE);
for (X = 0; X <= MaxY; X += 10) {
tgi_line (0, 0, MaxY, X);
tgi_line (0, 0, X, MaxY);
tgi_line (MaxY, MaxY, 0, MaxY-X);
tgi_line (MaxY, MaxY, MaxY-X, 0);
}
cgetc ();
tgi_clear ();
}
int main (void)
{
unsigned char Border;
#if DYN_DRV
/* Warn the user that the tgi driver is needed */
DoWarning ();
/* Load and initialize the driver */
tgi_load_driver (tgi_stddrv);
CheckError ("tgi_load_driver");
#else
/* Install the driver */
tgi_install (a2_lo_tgi);
CheckError ("tgi_install");
#endif
tgi_init ();
CheckError ("tgi_init");
tgi_clear ();
/* Get stuff from the driver */
MaxX = tgi_getmaxx ();
MaxY = tgi_getmaxy ();
AspectRatio = tgi_getaspectratio ();
/* Set the palette, set the border color */
Border = bordercolor (COLOR_BLACK);
/* Do graphics stuff */
DoCircles ();
DoCheckerboard ();
DoDiagram ();
DoLines ();
#if DYN_DRV
/* Unload the driver */
tgi_unload ();
#else
/* Uninstall the driver */
tgi_uninstall ();
#endif
/* Reset the border */
(void) bordercolor (Border);
/* Done */
printf ("Done\n");
return EXIT_SUCCESS;
}

View File

@ -1401,7 +1401,7 @@ var qs = (function (a) {
function preloadWorker(fileid) {
var tool = platform.getToolForFilename(fileid);
if (tool) worker.postMessage({preload:tool});
if (tool) worker.postMessage({preload:tool, platform:platform_id});
}
function initPlatform() {

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,5 @@
var Module;
if (typeof Module === 'undefined') Module = eval('(function() { try { return Module || {} } catch(e) { return {} } })()');
var Module = typeof Module !== 'undefined' ? Module : {};
if (!Module.expectedDataFileDownloads) {
Module.expectedDataFileDownloads = 0;
@ -20,8 +18,8 @@ Module.expectedDataFileDownloads++;
} else {
throw 'using preloaded data can only be done on a web page or in a web worker';
}
var PACKAGE_NAME = 'fs65.data';
var REMOTE_PACKAGE_BASE = 'fs65.data';
var PACKAGE_NAME = 'fs65-apple2.data';
var REMOTE_PACKAGE_BASE = 'fs65-apple2.data';
if (typeof Module['locateFilePackage'] === 'function' && !Module['locateFile']) {
Module['locateFile'] = Module['locateFilePackage'];
Module.printErr('warning: you defined Module.locateFilePackage, that has been renamed to Module.locateFile (using your locateFilePackage for now)');
@ -103,28 +101,32 @@ Module.expectedDataFileDownloads++;
if (!check) throw msg + new Error().stack;
}
Module['FS_createPath']('/', 'include', true, true);
Module['FS_createPath']('/include', 'joystick', true, true);
Module['FS_createPath']('/include', 'em', true, true);
Module['FS_createPath']('/include', 'mouse', true, true);
Module['FS_createPath']('/include', 'tgi', true, true);
Module['FS_createPath']('/include', 'geos', true, true);
Module['FS_createPath']('/include', 'em', true, true);
Module['FS_createPath']('/include', 'sys', true, true);
Module['FS_createPath']('/include', 'mouse', true, true);
Module['FS_createPath']('/include', 'joystick', true, true);
Module['FS_createPath']('/', 'asminc', true, true);
Module['FS_createPath']('/', 'cfg', true, true);
Module['FS_createPath']('/', 'lib', true, true);
Module['FS_createPath']('/', 'target', true, true);
Module['FS_createPath']('/target', 'apple2', true, true);
Module['FS_createPath']('/target/apple2', 'util', true, true);
Module['FS_createPath']('/target/apple2', 'drv', true, true);
Module['FS_createPath']('/target/apple2/drv', 'tgi', true, true);
Module['FS_createPath']('/target/apple2/drv', 'joy', true, true);
Module['FS_createPath']('/target/apple2/drv', 'emd', true, true);
Module['FS_createPath']('/target/apple2/drv', 'mou', true, true);
Module['FS_createPath']('/target/apple2/drv', 'emd', true, true);
Module['FS_createPath']('/target/apple2/drv', 'joy', true, true);
Module['FS_createPath']('/target/apple2/drv', 'ser', true, true);
Module['FS_createPath']('/target/apple2', 'util', true, true);
Module['FS_createPath']('/target', 'nes', true, true);
Module['FS_createPath']('/target/nes', 'drv', true, true);
Module['FS_createPath']('/target/nes/drv', 'tgi', true, true);
Module['FS_createPath']('/target/nes/drv', 'joy', true, true);
Module['FS_createPath']('/target', 'apple2enh', true, true);
Module['FS_createPath']('/target/apple2enh', 'util', true, true);
Module['FS_createPath']('/target/apple2enh', 'drv', true, true);
Module['FS_createPath']('/target/apple2enh/drv', 'tgi', true, true);
Module['FS_createPath']('/target/apple2enh/drv', 'mou', true, true);
Module['FS_createPath']('/target/apple2enh/drv', 'emd', true, true);
Module['FS_createPath']('/target/apple2enh/drv', 'joy', true, true);
Module['FS_createPath']('/target/apple2enh/drv', 'ser', true, true);
function DataRequest(start, end, crunched, audio) {
this.start = start;
@ -157,7 +159,7 @@ Module['FS_createPath']('/target/nes/drv', 'joy', true, true);
};
var files = metadata.files;
for (i = 0; i < files.length; ++i) {
for (var i = 0; i < files.length; ++i) {
new DataRequest(files[i].start, files[i].end, files[i].crunched, files[i].audio).open('GET', files[i].filename);
}
@ -177,13 +179,13 @@ Module['FS_createPath']('/target/nes/drv', 'joy', true, true);
DataRequest.prototype.byteArray = Module['HEAPU8'].subarray(ptr, ptr+byteArray.length);
var files = metadata.files;
for (i = 0; i < files.length; ++i) {
for (var i = 0; i < files.length; ++i) {
DataRequest.prototype.requests[files[i].filename].onload();
}
Module['removeRunDependency']('datafile_fs65.data');
Module['removeRunDependency']('datafile_fs65-apple2.data');
};
Module['addRunDependency']('datafile_fs65.data');
Module['addRunDependency']('datafile_fs65-apple2.data');
if (!Module.preloadResults) Module.preloadResults = {};
@ -203,12 +205,12 @@ Module['FS_createPath']('/target/nes/drv', 'joy', true, true);
Module["preRun"].push(runWithFS); // FS is not initialized yet, wait for it
}
Module['removeRunDependency']('fs65.js.metadata');
Module['removeRunDependency']('fs65-apple2.js.metadata');
}
var REMOTE_METADATA_NAME = typeof Module['locateFile'] === 'function' ?
Module['locateFile']('fs65.js.metadata') :
((Module['filePackagePrefixURL'] || '') + 'fs65.js.metadata');
Module['locateFile']('fs65-apple2.js.metadata') :
((Module['filePackagePrefixURL'] || '') + 'fs65-apple2.js.metadata');
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
@ -221,7 +223,7 @@ Module['FS_createPath']('/target/nes/drv', 'joy', true, true);
if (!Module['preRun']) Module['preRun'] = [];
Module["preRun"].push(function() {
Module['addRunDependency']('fs65.js.metadata');
Module['addRunDependency']('fs65-apple2.js.metadata');
});
})();

File diff suppressed because one or more lines are too long

71312
src/worker/fs65-atari8.data Normal file

File diff suppressed because one or more lines are too long

231
src/worker/fs65-atari8.js Normal file
View File

@ -0,0 +1,231 @@
var Module = typeof Module !== 'undefined' ? Module : {};
if (!Module.expectedDataFileDownloads) {
Module.expectedDataFileDownloads = 0;
Module.finishedDataFileDownloads = 0;
}
Module.expectedDataFileDownloads++;
(function() {
var loadPackage = function(metadata) {
var PACKAGE_PATH;
if (typeof window === 'object') {
PACKAGE_PATH = window['encodeURIComponent'](window.location.pathname.toString().substring(0, window.location.pathname.toString().lastIndexOf('/')) + '/');
} else if (typeof location !== 'undefined') {
// worker
PACKAGE_PATH = encodeURIComponent(location.pathname.toString().substring(0, location.pathname.toString().lastIndexOf('/')) + '/');
} else {
throw 'using preloaded data can only be done on a web page or in a web worker';
}
var PACKAGE_NAME = 'fs65-atari8.data';
var REMOTE_PACKAGE_BASE = 'fs65-atari8.data';
if (typeof Module['locateFilePackage'] === 'function' && !Module['locateFile']) {
Module['locateFile'] = Module['locateFilePackage'];
Module.printErr('warning: you defined Module.locateFilePackage, that has been renamed to Module.locateFile (using your locateFilePackage for now)');
}
var REMOTE_PACKAGE_NAME = typeof Module['locateFile'] === 'function' ?
Module['locateFile'](REMOTE_PACKAGE_BASE) :
((Module['filePackagePrefixURL'] || '') + REMOTE_PACKAGE_BASE);
var REMOTE_PACKAGE_SIZE = metadata.remote_package_size;
var PACKAGE_UUID = metadata.package_uuid;
function fetchRemotePackage(packageName, packageSize, callback, errback) {
var xhr = new XMLHttpRequest();
xhr.open('GET', packageName, true);
xhr.responseType = 'arraybuffer';
xhr.onprogress = function(event) {
var url = packageName;
var size = packageSize;
if (event.total) size = event.total;
if (event.loaded) {
if (!xhr.addedTotal) {
xhr.addedTotal = true;
if (!Module.dataFileDownloads) Module.dataFileDownloads = {};
Module.dataFileDownloads[url] = {
loaded: event.loaded,
total: size
};
} else {
Module.dataFileDownloads[url].loaded = event.loaded;
}
var total = 0;
var loaded = 0;
var num = 0;
for (var download in Module.dataFileDownloads) {
var data = Module.dataFileDownloads[download];
total += data.total;
loaded += data.loaded;
num++;
}
total = Math.ceil(total * Module.expectedDataFileDownloads/num);
if (Module['setStatus']) Module['setStatus']('Downloading data... (' + loaded + '/' + total + ')');
} else if (!Module.dataFileDownloads) {
if (Module['setStatus']) Module['setStatus']('Downloading data...');
}
};
xhr.onerror = function(event) {
throw new Error("NetworkError for: " + packageName);
}
xhr.onload = function(event) {
if (xhr.status == 200 || xhr.status == 304 || xhr.status == 206 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0
var packageData = xhr.response;
callback(packageData);
} else {
throw new Error(xhr.statusText + " : " + xhr.responseURL);
}
};
xhr.send(null);
};
function handleError(error) {
console.error('package error:', error);
};
var fetchedCallback = null;
var fetched = Module['getPreloadedPackage'] ? Module['getPreloadedPackage'](REMOTE_PACKAGE_NAME, REMOTE_PACKAGE_SIZE) : null;
if (!fetched) fetchRemotePackage(REMOTE_PACKAGE_NAME, REMOTE_PACKAGE_SIZE, function(data) {
if (fetchedCallback) {
fetchedCallback(data);
fetchedCallback = null;
} else {
fetched = data;
}
}, handleError);
function runWithFS() {
function assert(check, msg) {
if (!check) throw msg + new Error().stack;
}
Module['FS_createPath']('/', 'include', true, true);
Module['FS_createPath']('/include', 'em', true, true);
Module['FS_createPath']('/include', 'mouse', true, true);
Module['FS_createPath']('/include', 'tgi', true, true);
Module['FS_createPath']('/include', 'geos', true, true);
Module['FS_createPath']('/include', 'sys', true, true);
Module['FS_createPath']('/include', 'joystick', true, true);
Module['FS_createPath']('/', 'asminc', true, true);
Module['FS_createPath']('/', 'cfg', true, true);
Module['FS_createPath']('/', 'lib', true, true);
Module['FS_createPath']('/', 'target', true, true);
Module['FS_createPath']('/target', 'atari', true, true);
Module['FS_createPath']('/target/atari', 'util', true, true);
Module['FS_createPath']('/target/atari', 'drv', true, true);
Module['FS_createPath']('/target/atari/drv', 'tgi', true, true);
Module['FS_createPath']('/target/atari/drv', 'mou', true, true);
Module['FS_createPath']('/target/atari/drv', 'emd', true, true);
Module['FS_createPath']('/target/atari/drv', 'joy', true, true);
Module['FS_createPath']('/target/atari/drv', 'ser', true, true);
Module['FS_createPath']('/target', 'atari5200', true, true);
Module['FS_createPath']('/target/atari5200', 'drv', true, true);
Module['FS_createPath']('/target/atari5200/drv', 'joy', true, true);
Module['FS_createPath']('/target', 'atarixl', true, true);
Module['FS_createPath']('/target/atarixl', 'drv', true, true);
Module['FS_createPath']('/target/atarixl/drv', 'tgi', true, true);
Module['FS_createPath']('/target/atarixl/drv', 'mou', true, true);
Module['FS_createPath']('/target/atarixl/drv', 'emd', true, true);
Module['FS_createPath']('/target/atarixl/drv', 'joy', true, true);
Module['FS_createPath']('/target/atarixl/drv', 'ser', true, true);
function DataRequest(start, end, crunched, audio) {
this.start = start;
this.end = end;
this.crunched = crunched;
this.audio = audio;
}
DataRequest.prototype = {
requests: {},
open: function(mode, name) {
this.name = name;
this.requests[name] = this;
Module['addRunDependency']('fp ' + this.name);
},
send: function() {},
onload: function() {
var byteArray = this.byteArray.subarray(this.start, this.end);
this.finish(byteArray);
},
finish: function(byteArray) {
var that = this;
Module['FS_createDataFile'](this.name, null, byteArray, true, true, true); // canOwn this data in the filesystem, it is a slide into the heap that will never change
Module['removeRunDependency']('fp ' + that.name);
this.requests[this.name] = null;
}
};
var files = metadata.files;
for (var i = 0; i < files.length; ++i) {
new DataRequest(files[i].start, files[i].end, files[i].crunched, files[i].audio).open('GET', files[i].filename);
}
function processPackageData(arrayBuffer) {
Module.finishedDataFileDownloads++;
assert(arrayBuffer, 'Loading data file failed.');
assert(arrayBuffer instanceof ArrayBuffer, 'bad input to processPackageData');
var byteArray = new Uint8Array(arrayBuffer);
var curr;
// copy the entire loaded file into a spot in the heap. Files will refer to slices in that. They cannot be freed though
// (we may be allocating before malloc is ready, during startup).
if (Module['SPLIT_MEMORY']) Module.printErr('warning: you should run the file packager with --no-heap-copy when SPLIT_MEMORY is used, otherwise copying into the heap may fail due to the splitting');
var ptr = Module['getMemory'](byteArray.length);
Module['HEAPU8'].set(byteArray, ptr);
DataRequest.prototype.byteArray = Module['HEAPU8'].subarray(ptr, ptr+byteArray.length);
var files = metadata.files;
for (var i = 0; i < files.length; ++i) {
DataRequest.prototype.requests[files[i].filename].onload();
}
Module['removeRunDependency']('datafile_fs65-atari8.data');
};
Module['addRunDependency']('datafile_fs65-atari8.data');
if (!Module.preloadResults) Module.preloadResults = {};
Module.preloadResults[PACKAGE_NAME] = {fromCache: false};
if (fetched) {
processPackageData(fetched);
fetched = null;
} else {
fetchedCallback = processPackageData;
}
}
if (Module['calledRun']) {
runWithFS();
} else {
if (!Module['preRun']) Module['preRun'] = [];
Module["preRun"].push(runWithFS); // FS is not initialized yet, wait for it
}
Module['removeRunDependency']('fs65-atari8.js.metadata');
}
var REMOTE_METADATA_NAME = typeof Module['locateFile'] === 'function' ?
Module['locateFile']('fs65-atari8.js.metadata') :
((Module['filePackagePrefixURL'] || '') + 'fs65-atari8.js.metadata');
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
loadPackage(JSON.parse(xhr.responseText));
}
}
xhr.open('GET', REMOTE_METADATA_NAME, true);
xhr.overrideMimeType('application/json');
xhr.send(null);
if (!Module['preRun']) Module['preRun'] = [];
Module["preRun"].push(function() {
Module['addRunDependency']('fs65-atari8.js.metadata');
});
})();

File diff suppressed because one or more lines are too long

31103
src/worker/fs65-c64.data Normal file

File diff suppressed because one or more lines are too long

220
src/worker/fs65-c64.js Normal file
View File

@ -0,0 +1,220 @@
var Module = typeof Module !== 'undefined' ? Module : {};
if (!Module.expectedDataFileDownloads) {
Module.expectedDataFileDownloads = 0;
Module.finishedDataFileDownloads = 0;
}
Module.expectedDataFileDownloads++;
(function() {
var loadPackage = function(metadata) {
var PACKAGE_PATH;
if (typeof window === 'object') {
PACKAGE_PATH = window['encodeURIComponent'](window.location.pathname.toString().substring(0, window.location.pathname.toString().lastIndexOf('/')) + '/');
} else if (typeof location !== 'undefined') {
// worker
PACKAGE_PATH = encodeURIComponent(location.pathname.toString().substring(0, location.pathname.toString().lastIndexOf('/')) + '/');
} else {
throw 'using preloaded data can only be done on a web page or in a web worker';
}
var PACKAGE_NAME = 'fs65-c64.data';
var REMOTE_PACKAGE_BASE = 'fs65-c64.data';
if (typeof Module['locateFilePackage'] === 'function' && !Module['locateFile']) {
Module['locateFile'] = Module['locateFilePackage'];
Module.printErr('warning: you defined Module.locateFilePackage, that has been renamed to Module.locateFile (using your locateFilePackage for now)');
}
var REMOTE_PACKAGE_NAME = typeof Module['locateFile'] === 'function' ?
Module['locateFile'](REMOTE_PACKAGE_BASE) :
((Module['filePackagePrefixURL'] || '') + REMOTE_PACKAGE_BASE);
var REMOTE_PACKAGE_SIZE = metadata.remote_package_size;
var PACKAGE_UUID = metadata.package_uuid;
function fetchRemotePackage(packageName, packageSize, callback, errback) {
var xhr = new XMLHttpRequest();
xhr.open('GET', packageName, true);
xhr.responseType = 'arraybuffer';
xhr.onprogress = function(event) {
var url = packageName;
var size = packageSize;
if (event.total) size = event.total;
if (event.loaded) {
if (!xhr.addedTotal) {
xhr.addedTotal = true;
if (!Module.dataFileDownloads) Module.dataFileDownloads = {};
Module.dataFileDownloads[url] = {
loaded: event.loaded,
total: size
};
} else {
Module.dataFileDownloads[url].loaded = event.loaded;
}
var total = 0;
var loaded = 0;
var num = 0;
for (var download in Module.dataFileDownloads) {
var data = Module.dataFileDownloads[download];
total += data.total;
loaded += data.loaded;
num++;
}
total = Math.ceil(total * Module.expectedDataFileDownloads/num);
if (Module['setStatus']) Module['setStatus']('Downloading data... (' + loaded + '/' + total + ')');
} else if (!Module.dataFileDownloads) {
if (Module['setStatus']) Module['setStatus']('Downloading data...');
}
};
xhr.onerror = function(event) {
throw new Error("NetworkError for: " + packageName);
}
xhr.onload = function(event) {
if (xhr.status == 200 || xhr.status == 304 || xhr.status == 206 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0
var packageData = xhr.response;
callback(packageData);
} else {
throw new Error(xhr.statusText + " : " + xhr.responseURL);
}
};
xhr.send(null);
};
function handleError(error) {
console.error('package error:', error);
};
var fetchedCallback = null;
var fetched = Module['getPreloadedPackage'] ? Module['getPreloadedPackage'](REMOTE_PACKAGE_NAME, REMOTE_PACKAGE_SIZE) : null;
if (!fetched) fetchRemotePackage(REMOTE_PACKAGE_NAME, REMOTE_PACKAGE_SIZE, function(data) {
if (fetchedCallback) {
fetchedCallback(data);
fetchedCallback = null;
} else {
fetched = data;
}
}, handleError);
function runWithFS() {
function assert(check, msg) {
if (!check) throw msg + new Error().stack;
}
Module['FS_createPath']('/', 'include', true, true);
Module['FS_createPath']('/include', 'em', true, true);
Module['FS_createPath']('/include', 'mouse', true, true);
Module['FS_createPath']('/include', 'tgi', true, true);
Module['FS_createPath']('/include', 'geos', true, true);
Module['FS_createPath']('/include', 'sys', true, true);
Module['FS_createPath']('/include', 'joystick', true, true);
Module['FS_createPath']('/', 'asminc', true, true);
Module['FS_createPath']('/', 'cfg', true, true);
Module['FS_createPath']('/', 'lib', true, true);
Module['FS_createPath']('/', 'target', true, true);
Module['FS_createPath']('/target', 'c64', true, true);
Module['FS_createPath']('/target/c64', 'drv', true, true);
Module['FS_createPath']('/target/c64/drv', 'tgi', true, true);
Module['FS_createPath']('/target/c64/drv', 'mou', true, true);
Module['FS_createPath']('/target/c64/drv', 'emd', true, true);
Module['FS_createPath']('/target/c64/drv', 'joy', true, true);
Module['FS_createPath']('/target/c64/drv', 'ser', true, true);
function DataRequest(start, end, crunched, audio) {
this.start = start;
this.end = end;
this.crunched = crunched;
this.audio = audio;
}
DataRequest.prototype = {
requests: {},
open: function(mode, name) {
this.name = name;
this.requests[name] = this;
Module['addRunDependency']('fp ' + this.name);
},
send: function() {},
onload: function() {
var byteArray = this.byteArray.subarray(this.start, this.end);
this.finish(byteArray);
},
finish: function(byteArray) {
var that = this;
Module['FS_createDataFile'](this.name, null, byteArray, true, true, true); // canOwn this data in the filesystem, it is a slide into the heap that will never change
Module['removeRunDependency']('fp ' + that.name);
this.requests[this.name] = null;
}
};
var files = metadata.files;
for (var i = 0; i < files.length; ++i) {
new DataRequest(files[i].start, files[i].end, files[i].crunched, files[i].audio).open('GET', files[i].filename);
}
function processPackageData(arrayBuffer) {
Module.finishedDataFileDownloads++;
assert(arrayBuffer, 'Loading data file failed.');
assert(arrayBuffer instanceof ArrayBuffer, 'bad input to processPackageData');
var byteArray = new Uint8Array(arrayBuffer);
var curr;
// copy the entire loaded file into a spot in the heap. Files will refer to slices in that. They cannot be freed though
// (we may be allocating before malloc is ready, during startup).
if (Module['SPLIT_MEMORY']) Module.printErr('warning: you should run the file packager with --no-heap-copy when SPLIT_MEMORY is used, otherwise copying into the heap may fail due to the splitting');
var ptr = Module['getMemory'](byteArray.length);
Module['HEAPU8'].set(byteArray, ptr);
DataRequest.prototype.byteArray = Module['HEAPU8'].subarray(ptr, ptr+byteArray.length);
var files = metadata.files;
for (var i = 0; i < files.length; ++i) {
DataRequest.prototype.requests[files[i].filename].onload();
}
Module['removeRunDependency']('datafile_fs65-c64.data');
};
Module['addRunDependency']('datafile_fs65-c64.data');
if (!Module.preloadResults) Module.preloadResults = {};
Module.preloadResults[PACKAGE_NAME] = {fromCache: false};
if (fetched) {
processPackageData(fetched);
fetched = null;
} else {
fetchedCallback = processPackageData;
}
}
if (Module['calledRun']) {
runWithFS();
} else {
if (!Module['preRun']) Module['preRun'] = [];
Module["preRun"].push(runWithFS); // FS is not initialized yet, wait for it
}
Module['removeRunDependency']('fs65-c64.js.metadata');
}
var REMOTE_METADATA_NAME = typeof Module['locateFile'] === 'function' ?
Module['locateFile']('fs65-c64.js.metadata') :
((Module['filePackagePrefixURL'] || '') + 'fs65-c64.js.metadata');
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
loadPackage(JSON.parse(xhr.responseText));
}
}
xhr.open('GET', REMOTE_METADATA_NAME, true);
xhr.overrideMimeType('application/json');
xhr.send(null);
if (!Module['preRun']) Module['preRun'] = [];
Module["preRun"].push(function() {
Module['addRunDependency']('fs65-c64.js.metadata');
});
})();

File diff suppressed because one or more lines are too long

28519
src/worker/fs65-nes.data Normal file

File diff suppressed because one or more lines are too long

217
src/worker/fs65-nes.js Normal file
View File

@ -0,0 +1,217 @@
var Module = typeof Module !== 'undefined' ? Module : {};
if (!Module.expectedDataFileDownloads) {
Module.expectedDataFileDownloads = 0;
Module.finishedDataFileDownloads = 0;
}
Module.expectedDataFileDownloads++;
(function() {
var loadPackage = function(metadata) {
var PACKAGE_PATH;
if (typeof window === 'object') {
PACKAGE_PATH = window['encodeURIComponent'](window.location.pathname.toString().substring(0, window.location.pathname.toString().lastIndexOf('/')) + '/');
} else if (typeof location !== 'undefined') {
// worker
PACKAGE_PATH = encodeURIComponent(location.pathname.toString().substring(0, location.pathname.toString().lastIndexOf('/')) + '/');
} else {
throw 'using preloaded data can only be done on a web page or in a web worker';
}
var PACKAGE_NAME = 'fs65-nes.data';
var REMOTE_PACKAGE_BASE = 'fs65-nes.data';
if (typeof Module['locateFilePackage'] === 'function' && !Module['locateFile']) {
Module['locateFile'] = Module['locateFilePackage'];
Module.printErr('warning: you defined Module.locateFilePackage, that has been renamed to Module.locateFile (using your locateFilePackage for now)');
}
var REMOTE_PACKAGE_NAME = typeof Module['locateFile'] === 'function' ?
Module['locateFile'](REMOTE_PACKAGE_BASE) :
((Module['filePackagePrefixURL'] || '') + REMOTE_PACKAGE_BASE);
var REMOTE_PACKAGE_SIZE = metadata.remote_package_size;
var PACKAGE_UUID = metadata.package_uuid;
function fetchRemotePackage(packageName, packageSize, callback, errback) {
var xhr = new XMLHttpRequest();
xhr.open('GET', packageName, true);
xhr.responseType = 'arraybuffer';
xhr.onprogress = function(event) {
var url = packageName;
var size = packageSize;
if (event.total) size = event.total;
if (event.loaded) {
if (!xhr.addedTotal) {
xhr.addedTotal = true;
if (!Module.dataFileDownloads) Module.dataFileDownloads = {};
Module.dataFileDownloads[url] = {
loaded: event.loaded,
total: size
};
} else {
Module.dataFileDownloads[url].loaded = event.loaded;
}
var total = 0;
var loaded = 0;
var num = 0;
for (var download in Module.dataFileDownloads) {
var data = Module.dataFileDownloads[download];
total += data.total;
loaded += data.loaded;
num++;
}
total = Math.ceil(total * Module.expectedDataFileDownloads/num);
if (Module['setStatus']) Module['setStatus']('Downloading data... (' + loaded + '/' + total + ')');
} else if (!Module.dataFileDownloads) {
if (Module['setStatus']) Module['setStatus']('Downloading data...');
}
};
xhr.onerror = function(event) {
throw new Error("NetworkError for: " + packageName);
}
xhr.onload = function(event) {
if (xhr.status == 200 || xhr.status == 304 || xhr.status == 206 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0
var packageData = xhr.response;
callback(packageData);
} else {
throw new Error(xhr.statusText + " : " + xhr.responseURL);
}
};
xhr.send(null);
};
function handleError(error) {
console.error('package error:', error);
};
var fetchedCallback = null;
var fetched = Module['getPreloadedPackage'] ? Module['getPreloadedPackage'](REMOTE_PACKAGE_NAME, REMOTE_PACKAGE_SIZE) : null;
if (!fetched) fetchRemotePackage(REMOTE_PACKAGE_NAME, REMOTE_PACKAGE_SIZE, function(data) {
if (fetchedCallback) {
fetchedCallback(data);
fetchedCallback = null;
} else {
fetched = data;
}
}, handleError);
function runWithFS() {
function assert(check, msg) {
if (!check) throw msg + new Error().stack;
}
Module['FS_createPath']('/', 'include', true, true);
Module['FS_createPath']('/include', 'em', true, true);
Module['FS_createPath']('/include', 'mouse', true, true);
Module['FS_createPath']('/include', 'tgi', true, true);
Module['FS_createPath']('/include', 'geos', true, true);
Module['FS_createPath']('/include', 'sys', true, true);
Module['FS_createPath']('/include', 'joystick', true, true);
Module['FS_createPath']('/', 'asminc', true, true);
Module['FS_createPath']('/', 'cfg', true, true);
Module['FS_createPath']('/', 'lib', true, true);
Module['FS_createPath']('/', 'target', true, true);
Module['FS_createPath']('/target', 'nes', true, true);
Module['FS_createPath']('/target/nes', 'drv', true, true);
Module['FS_createPath']('/target/nes/drv', 'tgi', true, true);
Module['FS_createPath']('/target/nes/drv', 'joy', true, true);
function DataRequest(start, end, crunched, audio) {
this.start = start;
this.end = end;
this.crunched = crunched;
this.audio = audio;
}
DataRequest.prototype = {
requests: {},
open: function(mode, name) {
this.name = name;
this.requests[name] = this;
Module['addRunDependency']('fp ' + this.name);
},
send: function() {},
onload: function() {
var byteArray = this.byteArray.subarray(this.start, this.end);
this.finish(byteArray);
},
finish: function(byteArray) {
var that = this;
Module['FS_createDataFile'](this.name, null, byteArray, true, true, true); // canOwn this data in the filesystem, it is a slide into the heap that will never change
Module['removeRunDependency']('fp ' + that.name);
this.requests[this.name] = null;
}
};
var files = metadata.files;
for (var i = 0; i < files.length; ++i) {
new DataRequest(files[i].start, files[i].end, files[i].crunched, files[i].audio).open('GET', files[i].filename);
}
function processPackageData(arrayBuffer) {
Module.finishedDataFileDownloads++;
assert(arrayBuffer, 'Loading data file failed.');
assert(arrayBuffer instanceof ArrayBuffer, 'bad input to processPackageData');
var byteArray = new Uint8Array(arrayBuffer);
var curr;
// copy the entire loaded file into a spot in the heap. Files will refer to slices in that. They cannot be freed though
// (we may be allocating before malloc is ready, during startup).
if (Module['SPLIT_MEMORY']) Module.printErr('warning: you should run the file packager with --no-heap-copy when SPLIT_MEMORY is used, otherwise copying into the heap may fail due to the splitting');
var ptr = Module['getMemory'](byteArray.length);
Module['HEAPU8'].set(byteArray, ptr);
DataRequest.prototype.byteArray = Module['HEAPU8'].subarray(ptr, ptr+byteArray.length);
var files = metadata.files;
for (var i = 0; i < files.length; ++i) {
DataRequest.prototype.requests[files[i].filename].onload();
}
Module['removeRunDependency']('datafile_fs65-nes.data');
};
Module['addRunDependency']('datafile_fs65-nes.data');
if (!Module.preloadResults) Module.preloadResults = {};
Module.preloadResults[PACKAGE_NAME] = {fromCache: false};
if (fetched) {
processPackageData(fetched);
fetched = null;
} else {
fetchedCallback = processPackageData;
}
}
if (Module['calledRun']) {
runWithFS();
} else {
if (!Module['preRun']) Module['preRun'] = [];
Module["preRun"].push(runWithFS); // FS is not initialized yet, wait for it
}
Module['removeRunDependency']('fs65-nes.js.metadata');
}
var REMOTE_METADATA_NAME = typeof Module['locateFile'] === 'function' ?
Module['locateFile']('fs65-nes.js.metadata') :
((Module['filePackagePrefixURL'] || '') + 'fs65-nes.js.metadata');
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
loadPackage(JSON.parse(xhr.responseText));
}
}
xhr.open('GET', REMOTE_METADATA_NAME, true);
xhr.overrideMimeType('application/json');
xhr.send(null);
if (!Module['preRun']) Module['preRun'] = [];
Module["preRun"].push(function() {
Module['addRunDependency']('fs65-nes.js.metadata');
});
})();

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -83,7 +83,7 @@ var PLATFORM_PARAMS = {
},
'apple2': {
define: '__APPLE2__',
cfgfile: 'apple2.cfg',
cfgfile: 'apple2-hgr.cfg',
libargs: ['apple2.lib'],
code_offset: 0x803, // TODO: parse segment list
},
@ -586,7 +586,7 @@ function assemblelinkCA65(code, platform) {
printErr:msvcErrorMatcher(errors),
});
var FS = CA65['FS'];
setupFS(FS, '65');
setupFS(FS, '65-'+platform.split('-')[0]);
FS.writeFile("main.s", code, {encoding:'utf8'});
starttime();
CA65.callMain(['-v', '-g', '-I', '/share/asminc', '-l', 'main.lst', "main.s"]);
@ -610,7 +610,7 @@ function assemblelinkCA65(code, platform) {
});
var FS = LD65['FS'];
var cfgfile = '/' + platform + '.cfg';
setupFS(FS, '65');
setupFS(FS, '65-'+platform.split('-')[0]);
FS.writeFile("main.o", objout, {encoding:'binary'});
var libargs = params.libargs;
starttime();
@ -683,7 +683,7 @@ function compileCC65(code, platform) {
printErr:match_fn,
});
var FS = CC65['FS'];
setupFS(FS, '65');
setupFS(FS, '65-'+platform.split('-')[0]);
FS.writeFile("main.c", code, {encoding:'utf8'});
starttime();
CC65.callMain(['-T', '-g', /*'-Cl',*/
@ -1360,8 +1360,14 @@ var TOOLS = {
}
var TOOL_PRELOADFS = {
'cc65': '65',
'ca65': '65',
'cc65-apple2': '65-apple2',
'ca65-apple2': '65-apple2',
'cc65-c64': '65-c64',
'ca65-c64': '65-c64',
'cc65-nes': '65-nes',
'ca65-nes': '65-nes',
'cc65-atari8': '65-atari8',
'ca65-atari8': '65-atari8',
'sdasz80': 'sdcc',
'sdcc': 'sdcc',
}
@ -1369,7 +1375,10 @@ var TOOL_PRELOADFS = {
function handleMessage(data) {
if (data.preload) {
var fs = TOOL_PRELOADFS[data.preload];
if (fs && !fsMeta[fs]) loadFilesystem(fs);
if (!fs && data.platform)
fs = TOOL_PRELOADFS[data.preload+'-'+data.platform.split('-')[0]];
if (fs && !fsMeta[fs])
loadFilesystem(fs);
return;
}
// (code,platform,tool)