fixed plasma vm bug, new plasm binary, cc65 fixes

This commit is contained in:
Steven Hugg 2017-01-10 03:18:54 -05:00
parent d64317ac11
commit 72a835f8f9
3 changed files with 187 additions and 124 deletions

View File

@ -174,6 +174,7 @@ var Apple2Platform = function(mainElement) {
grparams.grswitch = grswitch;
ap2disp.updateScreen();
video.updateFrame();
soundstate = 0; // to prevent clicking
// TODO: reset debug state
});
}
@ -881,7 +882,7 @@ var apple2_charset = [
// public domain ROM
var APPLEIIGO_LZG = [
76,90,71,0,0,48,0,0,0,10,171,116,213,197,126,1,25,52,55,59,65,80,80,76,69,73,73,71,79,32,82,79,
76,90,71,0,0,48,0,0,0,10,174,5,108,198,141,1,25,52,55,59,65,80,80,76,69,73,73,71,79,32,82,79,
77,49,46,49,255,59,31,59,31,59,31,59,31,59,31,59,31,59,31,59,3,133,109,132,110,56,165,150,229,155,133,94,
168,165,151,229,156,170,232,152,240,35,165,150,56,229,94,133,150,176,3,198,151,56,165,148,55,3,148,176,8,198,149,144,
4,177,150,145,148,136,208,249,59,194,198,151,198,149,202,208,242,96,52,30,128,59,27,255,255,32,0,224,52,30,67,59,
@ -894,77 +895,77 @@ var APPLEIIGO_LZG = [
0,5,55,195,55,78,52,5,3,96,55,3,6,55,195,144,55,25,7,55,3,76,64,224,59,65,0,32,190,224,76,74,
224,104,24,105,1,133,244,104,105,0,133,245,165,226,72,165,225,72,165,227,133,225,165,228,133,226,160,0,169,225,133,250,
76,243,0,104,133,230,104,133,231,160,2,177,230,133,245,136,59,129,244,136,52,12,33,52,28,31,55,159,226,133,250,120,
141,3,192,55,35,160,16,185,127,225,153,238,0,136,208,247,132,225,169,128,133,226,162,16,96,234,59,28,59,8,115,228,
128,226,145,226,182,226,90,227,100,227,118,227,127,227,74,227,138,227,153,227,169,227,185,227,201,227,235,227,162,226,24,228,
63,228,41,228,142,228,102,229,125,59,161,164,228,239,0,83,228,95,228,105,228,96,232,109,232,66,232,81,232,151,231,173,
231,211,231,243,231,195,231,227,231,23,232,3,232,30,232,122,232,139,232,235,232,60,233,110,233,133,233,240,0,248,228,15,
229,124,229,148,229,234,229,12,230,228,230,247,230,132,230,155,230,183,230,203,230,15,231,47,231,84,231,115,231,232,200,240,
8,185,255,255,133,249,108,0,225,230,245,208,244,52,28,171,59,30,59,3,52,28,248,52,9,248,193,52,28,248,122,232,
183,232,14,233,60,233,106,233,129,233,240,0,41,229,70,229,173,229,203,229,49,230,89,52,19,248,181,192,24,117,193,149,
193,181,208,117,209,149,209,232,76,240,0,181,193,56,245,192,55,9,209,245,208,52,5,9,192,10,54,208,52,13,29,132,
229,160,16,181,193,73,255,133,230,181,209,59,161,231,169,0,149,193,70,231,102,230,176,12,149,209,181,192,52,6,36,22,
192,54,208,136,208,231,55,43,164,229,55,45,169,0,52,2,82,192,169,0,245,208,149,208,96,55,59,17,169,0,133,230,
133,231,181,208,41,128,133,224,16,5,32,235,226,230,224,181,209,16,9,232,55,2,202,230,224,208,4,21,193,240,37,22,
193,54,209,136,144,249,38,230,38,231,165,230,213,192,165,231,245,208,144,9,133,55,4,245,192,133,230,56,54,55,86,208,
226,232,164,229,96,52,11,87,76,240,0,32,249,226,70,224,176,233,55,194,165,230,149,55,51,149,208,165,224,48,215,55,
10,246,192,208,2,246,55,93,181,55,1,214,208,214,192,55,3,169,255,85,55,119,255,85,55,247,181,193,53,52,3,255,
53,52,6,255,193,21,55,136,21,52,7,8,55,39,55,8,55,39,52,37,11,181,192,201,8,144,10,180,193,148,209,160,
0,148,193,233,8,168,240,7,52,3,181,208,249,52,4,248,52,5,26,16,180,209,148,193,192,128,160,0,144,1,136,148,
209,56,55,96,12,181,209,201,128,106,118,193,136,208,248,52,38,37,181,192,21,208,240,2,169,255,73,255,149,192,52,5,
136,21,209,55,33,52,5,15,149,193,52,38,149,21,208,21,55,82,6,52,8,12,202,181,193,149,192,181,209,55,238,192,
72,181,208,72,55,142,104,149,208,104,149,52,2,225,202,169,0,52,5,76,202,200,208,2,230,245,177,244,52,34,46,52,
13,9,52,6,1,52,8,14,152,24,101,244,133,55,163,168,101,245,133,245,149,208,177,244,168,52,13,21,52,5,19,55,
17,73,255,24,101,227,133,227,55,38,255,101,228,133,228,55,101,145,227,136,192,255,208,247,200,55,239,181,192,133,230,181,
208,133,231,132,229,160,0,177,230,149,192,148,208,52,5,239,52,12,15,200,59,129,52,14,18,141,2,192,52,8,44,52,
130,128,52,19,21,52,5,50,55,216,52,5,198,202,24,101,225,52,2,185,101,226,52,3,208,52,5,14,132,229,168,202,
177,55,144,52,5,99,52,13,16,200,59,129,52,15,17,141,2,192,52,6,44,141,3,192,52,21,22,55,178,52,13,23,
133,230,52,6,1,52,5,221,202,52,7,245,52,25,26,52,40,0,52,18,29,52,5,237,52,3,66,52,26,103,52,8,
32,52,3,72,52,6,35,181,193,52,98,192,133,231,181,192,52,2,104,145,230,232,52,69,123,52,5,15,55,77,181,192,
145,230,200,181,208,52,7,20,52,8,228,55,18,225,52,18,12,55,102,52,19,17,52,22,36,52,21,174,52,7,141,52,
57,27,52,8,150,52,27,29,145,230,52,28,60,55,220,181,192,213,193,208,28,181,208,213,209,208,22,169,255,232,52,102,
124,55,78,240,55,142,234,169,0,52,7,14,193,213,192,52,162,39,80,2,73,128,16,210,48,230,55,94,181,208,245,209,
55,72,48,194,16,214,52,10,8,16,178,48,198,52,10,40,48,162,16,182,232,181,207,21,191,208,20,52,3,134,59,131,
76,240,0,55,204,236,165,245,133,231,165,244,55,141,24,113,244,133,230,165,231,55,132,55,3,245,165,52,226,145,136,55,
163,191,213,192,208,193,181,207,213,208,240,207,208,185,55,199,198,55,135,172,208,190,55,135,181,207,245,208,48,179,16,157,
232,181,192,213,191,181,208,245,207,48,166,16,144,165,244,24,117,192,133,244,165,245,117,208,133,245,52,130,26,52,48,16,
165,245,72,165,244,72,152,72,32,57,233,104,168,104,133,244,104,133,245,25,3,0,28,52,26,36,141,2,192,88,55,40,
120,141,3,192,52,7,44,226,55,172,52,102,157,232,52,24,79,52,15,27,52,24,70,108,230,0,200,177,244,72,73,255,
56,52,130,97,133,225,52,132,97,133,226,55,13,10,168,240,13,181,208,136,145,225,181,192,232,59,161,208,243,160,2,55,
41,52,2,67,104,24,101,225,133,227,52,98,249,133,228,104,133,225,104,133,226,96,55,79,165,55,13,165,52,8,11,25,
30,1,212,59,31,59,31,59,31,59,30,0,201,206,176,238,201,201,144,234,201,204,240,230,208,232,25,12,1,185,72,74,
41,3,9,4,133,41,104,41,24,144,2,105,127,133,40,10,10,5,40,133,40,52,94,61,0,0,165,37,32,193,251,101,
32,52,29,75,59,21,165,34,72,32,36,252,165,40,133,42,165,41,133,43,164,33,136,104,105,1,197,35,176,13,55,78,
177,40,145,42,136,16,249,48,225,160,0,32,158,252,176,134,164,36,169,160,145,40,200,196,33,144,249,52,30,199,59,27,
164,36,177,40,72,41,63,9,64,145,40,104,108,56,52,19,27,32,12,253,32,165,251,59,161,201,155,240,243,52,28,141,
59,6,32,142,253,165,51,32,237,253,162,1,138,240,243,202,32,53,253,201,149,208,2,177,40,201,224,144,2,41,223,157,
0,2,201,141,208,178,32,156,252,169,141,208,91,164,61,166,60,55,39,32,64,249,160,0,169,173,76,237,253,52,28,87,
59,31,59,31,59,31,59,31,59,31,59,31,59,31,59,31,59,31,59,31,59,31,59,31,59,28,59,7,169,0,133,28,
165,230,133,27,160,0,132,26,165,28,145,26,32,126,244,200,208,246,230,27,165,27,41,31,208,238,96,133,226,134,224,132,
225,72,41,192,133,38,74,74,5,38,133,38,104,133,39,10,10,10,38,39,59,66,102,38,165,39,41,31,5,230,133,39,
138,192,0,240,5,160,35,105,4,200,233,7,176,251,132,229,170,189,185,244,133,48,152,74,165,228,133,28,176,25,28,0,
35,59,4,10,201,192,16,6,165,28,73,127,133,28,52,254,218,59,31,59,31,59,31,59,31,59,31,59,31,59,28,59,
10,74,8,32,71,248,40,169,15,144,2,105,224,133,46,177,38,69,48,37,46,81,38,145,38,96,32,0,248,196,44,176,
17,200,32,14,248,144,246,105,1,72,55,8,104,197,45,144,245,96,160,47,208,2,160,39,132,45,160,39,169,0,133,48,
32,40,248,136,16,246,96,25,5,4,126,39,25,6,4,126,38,10,10,52,130,52,96,165,48,24,105,3,41,15,133,48,
10,59,1,5,48,133,48,52,103,223,144,4,74,59,1,41,15,52,107,240,168,74,144,9,106,176,16,201,162,240,12,41,
135,74,170,189,98,249,32,121,248,208,4,160,128,169,0,170,189,166,249,133,46,41,3,133,47,152,41,143,170,152,160,3,
224,138,240,11,74,144,8,74,74,9,32,136,208,250,200,136,208,242,52,159,59,59,31,59,31,59,20,216,32,132,254,32,
47,251,32,147,254,32,137,254,173,88,192,173,90,192,173,93,192,173,95,192,173,255,207,44,16,192,216,32,58,255,32,96,
251,169,0,133,0,169,198,133,1,108,52,30,111,59,29,25,3,19,108,221,219,199,207,52,10,13,173,112,192,160,0,234,
234,189,100,192,16,4,200,208,248,136,96,169,0,133,72,173,86,192,173,84,192,173,81,192,169,0,240,11,173,80,192,173,
83,192,32,54,248,169,20,133,34,55,22,32,169,40,133,33,169,24,133,35,169,23,133,37,76,34,252,32,88,252,160,9,
185,8,251,153,14,4,136,208,247,96,173,243,3,73,165,141,244,3,96,201,141,208,24,172,0,192,16,19,192,147,208,15,
44,16,192,55,68,251,192,131,240,3,55,4,76,253,251,52,12,148,25,29,7,248,40,133,40,96,201,135,208,18,169,64,
32,168,252,160,192,169,12,59,193,173,48,192,136,208,245,96,164,36,145,40,230,36,165,36,197,33,176,102,96,201,160,176,
239,168,16,236,201,141,240,90,201,138,59,97,136,208,201,198,36,16,232,165,33,133,36,198,36,165,34,197,37,176,11,198,
37,25,28,7,248,0,72,32,36,252,32,158,252,160,0,104,105,0,197,35,144,240,176,202,165,34,133,37,160,0,132,36,
240,228,169,0,133,36,230,55,62,55,16,182,198,37,25,29,7,248,25,6,7,248,56,72,233,1,208,252,104,59,129,246,
96,230,66,208,2,230,67,165,60,197,62,165,61,229,63,230,60,55,6,61,52,125,244,59,18,25,13,7,248,230,78,208,
2,230,79,44,0,192,16,245,145,40,173,0,192,44,16,192,96,25,10,7,248,254,96,165,50,72,169,255,133,50,189,0,
2,32,237,253,104,55,129,201,136,240,29,201,152,240,10,224,248,144,3,32,58,255,232,208,19,169,220,55,21,25,10,7,
248,254,25,30,7,248,59,27,0,72,52,162,88,32,229,253,104,41,15,9,176,201,186,144,2,105,6,108,54,0,201,160,
144,2,37,50,132,53,72,32,120,251,104,164,53,52,49,47,64,52,10,5,52,11,24,177,60,145,66,32,180,252,144,247,
52,190,97,59,1,160,63,208,2,160,255,132,50,52,98,82,62,162,56,160,27,208,8,55,130,54,160,240,165,62,41,15,
240,6,9,192,160,0,240,2,169,253,148,0,149,1,96,234,234,76,0,224,52,30,115,59,29,59,13,169,135,76,237,253,
165,72,72,165,69,166,70,164,71,52,110,22,52,62,27,59,30,59,14,245,3,251,3,98,250,98,250
141,3,192,55,35,160,16,185,127,225,153,238,0,136,208,247,132,227,132,225,169,191,133,55,24,162,16,96,234,59,28,59,
4,115,228,128,226,145,226,182,226,90,227,100,227,118,227,127,227,74,227,138,227,153,227,169,227,185,227,201,227,235,227,162,
226,24,228,63,228,41,228,142,228,102,229,125,59,161,164,228,239,0,83,228,95,228,105,228,96,232,109,232,66,232,81,232,
151,231,173,231,211,231,243,231,195,231,227,231,23,232,3,232,30,232,122,232,139,232,235,232,60,233,110,233,133,233,240,0,
248,228,15,229,124,229,148,229,234,229,12,230,228,230,247,230,132,230,155,230,183,230,203,230,15,231,47,231,84,231,115,231,
232,200,240,8,185,255,255,133,249,108,0,225,230,245,208,244,52,28,171,59,30,59,3,52,28,248,52,9,248,193,52,28,
248,122,232,183,232,14,233,60,233,106,233,129,233,240,0,41,229,70,229,173,229,203,229,49,230,89,52,19,248,181,192,24,
117,193,149,193,181,208,117,209,149,209,232,76,240,0,181,193,56,245,192,55,9,209,245,208,52,5,9,192,10,54,208,52,
13,29,132,229,160,16,181,193,73,255,133,230,181,209,59,161,231,169,0,149,193,70,231,102,230,176,12,149,209,181,192,52,
6,36,22,192,54,208,136,208,231,55,43,164,229,55,45,169,0,52,2,82,192,169,0,245,208,149,208,96,55,59,17,169,
0,133,230,133,231,181,208,41,128,133,224,16,5,32,235,226,230,224,181,209,16,9,232,55,2,202,230,224,208,4,21,193,
240,37,22,193,54,209,136,144,249,38,230,38,231,165,230,213,192,165,231,245,208,144,9,133,55,4,245,192,133,230,56,54,
55,86,208,226,232,164,229,96,52,11,87,76,240,0,32,249,226,70,224,176,233,55,194,165,230,149,55,51,149,208,165,224,
48,215,55,10,246,192,208,2,246,55,93,181,55,1,214,208,214,192,55,3,169,255,85,55,119,255,85,55,247,181,193,53,
52,3,255,53,52,6,255,193,21,55,136,21,52,7,8,55,39,55,8,55,39,52,37,11,181,192,201,8,144,10,180,193,
148,209,160,0,148,193,233,8,168,240,7,52,3,181,208,249,52,4,248,52,5,26,16,180,209,148,193,192,128,160,0,144,
1,136,148,209,56,55,96,12,181,209,201,128,106,118,193,136,208,248,52,38,37,181,192,21,208,240,2,169,255,73,255,149,
192,52,5,136,21,209,55,33,52,5,15,149,193,52,38,149,21,208,21,55,82,6,52,8,12,202,181,193,149,192,181,209,
55,238,192,72,181,208,72,55,142,104,149,208,104,149,52,2,225,202,169,0,52,5,76,202,200,208,2,230,245,177,244,52,
34,46,52,13,9,52,6,1,52,8,14,152,24,101,244,133,55,163,168,101,245,133,245,149,208,177,244,168,52,13,21,52,
5,19,55,17,73,255,24,101,227,133,227,55,38,255,101,228,133,228,55,101,145,227,136,192,255,208,247,200,55,239,181,192,
133,230,181,208,133,231,132,229,160,0,177,230,149,192,148,208,52,5,239,52,12,15,200,59,129,52,14,18,141,2,192,52,
8,44,52,130,128,52,19,21,52,5,50,55,216,52,5,198,202,24,101,225,52,2,185,101,226,52,3,208,52,5,14,132,
229,168,202,177,55,144,52,5,99,52,13,16,200,59,129,52,15,17,141,2,192,52,6,44,141,3,192,52,21,22,55,178,
52,13,23,133,230,52,6,1,52,5,221,202,52,7,245,52,25,26,52,40,0,52,18,29,52,5,237,52,3,66,52,26,
103,52,8,32,52,3,72,52,6,35,181,193,52,98,192,133,231,181,192,52,2,104,145,230,232,52,69,123,52,5,15,55,
77,181,192,145,230,200,181,208,52,7,20,52,8,228,55,18,225,52,18,12,55,102,52,19,17,52,22,36,52,21,174,52,
7,141,52,57,27,52,8,150,52,27,29,145,230,52,28,60,55,220,181,192,213,193,208,28,181,208,213,209,208,22,169,255,
232,52,102,124,55,78,240,55,142,234,169,0,52,7,14,193,213,192,52,162,39,80,2,73,128,16,210,48,230,55,94,181,
208,245,209,55,72,48,194,16,214,52,10,8,16,178,48,198,52,10,40,48,162,16,182,232,181,207,21,191,208,20,52,3,
134,59,131,76,240,0,55,204,236,165,245,133,231,165,244,55,141,24,113,244,133,230,165,231,55,132,55,3,245,165,52,226,
145,136,55,163,191,213,192,208,193,181,207,213,208,240,207,208,185,55,199,198,55,135,172,208,190,55,135,181,207,245,208,48,
179,16,157,232,181,192,213,191,181,208,245,207,48,166,16,144,165,244,24,117,192,133,244,165,245,117,208,133,245,52,130,26,
52,48,16,165,245,72,165,244,72,152,72,32,57,233,104,168,104,133,244,104,133,245,25,3,0,28,52,26,36,141,2,192,
88,55,40,120,141,3,192,52,7,44,226,55,172,52,102,157,232,52,24,79,52,15,27,52,24,70,108,230,0,200,177,244,
72,73,255,56,52,130,97,133,225,52,132,97,133,226,55,13,10,168,240,13,181,208,136,145,225,181,192,232,59,161,208,243,
160,2,55,41,52,2,67,104,24,101,225,133,227,52,98,249,133,228,104,133,225,104,133,226,96,55,79,165,55,13,165,52,
8,11,25,30,1,212,59,31,59,31,59,31,59,30,0,201,206,176,238,201,201,144,234,201,204,240,230,208,232,25,12,1,
185,72,74,41,3,9,4,133,41,104,41,24,144,2,105,127,133,40,10,10,5,40,133,40,52,94,61,0,0,165,37,32,
193,251,101,32,52,29,75,59,21,165,34,72,32,36,252,165,40,133,42,165,41,133,43,164,33,136,104,105,1,197,35,176,
13,55,78,177,40,145,42,136,16,249,48,225,160,0,32,158,252,176,134,164,36,169,160,145,40,200,196,33,144,249,52,30,
199,59,27,164,36,177,40,72,41,63,9,64,145,40,104,108,56,52,19,27,32,12,253,32,165,251,59,161,201,155,240,243,
52,28,141,59,6,32,142,253,165,51,32,237,253,162,1,138,240,243,202,32,53,253,201,149,208,2,177,40,201,224,144,2,
41,223,157,0,2,201,141,208,178,32,156,252,169,141,208,91,164,61,166,60,55,39,32,64,249,160,0,169,173,76,237,253,
52,28,87,59,31,59,31,59,31,59,31,59,31,59,31,59,31,59,31,59,31,59,31,59,31,59,31,59,28,59,7,169,
0,133,28,165,230,133,27,160,0,132,26,165,28,145,26,32,126,244,200,208,246,230,27,165,27,41,31,208,238,96,133,226,
134,224,132,225,72,41,192,133,38,74,74,5,38,133,38,104,133,39,10,10,10,38,39,59,66,102,38,165,39,41,31,5,
230,133,39,138,192,0,240,5,160,35,105,4,200,233,7,176,251,132,229,170,189,185,244,133,48,152,74,165,228,133,28,176,
25,28,0,35,59,4,10,201,192,16,6,165,28,73,127,133,28,52,254,218,59,31,59,31,59,31,59,31,59,31,59,31,
59,28,59,10,74,8,32,71,248,40,169,15,144,2,105,224,133,46,177,38,69,48,37,46,81,38,145,38,96,32,0,248,
196,44,176,17,200,32,14,248,144,246,105,1,72,55,8,104,197,45,144,245,96,160,47,208,2,160,39,132,45,160,39,169,
0,133,48,32,40,248,136,16,246,96,25,5,4,126,39,25,6,4,126,38,10,10,52,130,52,96,165,48,24,105,3,41,
15,133,48,10,59,1,5,48,133,48,52,103,223,144,4,74,59,1,41,15,52,107,240,168,74,144,9,106,176,16,201,162,
240,12,41,135,74,170,189,98,249,32,121,248,208,4,160,128,169,0,170,189,166,249,133,46,41,3,133,47,152,41,143,170,
152,160,3,224,138,240,11,74,144,8,74,74,9,32,136,208,250,200,136,208,242,52,159,59,59,31,59,31,59,20,216,32,
132,254,32,47,251,32,147,254,32,137,254,173,88,192,173,90,192,173,93,192,173,95,192,173,255,207,44,16,192,216,32,58,
255,32,96,251,169,0,133,0,169,198,133,1,108,52,30,111,59,29,25,3,19,108,221,219,199,207,52,10,13,173,112,192,
160,0,234,234,189,100,192,16,4,200,208,248,136,96,169,0,133,72,173,86,192,173,84,192,173,81,192,169,0,240,11,173,
80,192,173,83,192,32,54,248,169,20,133,34,55,22,32,169,40,133,33,169,24,133,35,169,23,133,37,76,34,252,32,88,
252,160,9,185,8,251,153,14,4,136,208,247,96,173,243,3,73,165,141,244,3,96,201,141,208,24,172,0,192,16,19,192,
147,208,15,44,16,192,55,68,251,192,131,240,3,55,4,76,253,251,52,12,148,25,29,7,248,40,133,40,96,201,135,208,
18,169,64,32,168,252,160,192,169,12,59,193,173,48,192,136,208,245,96,164,36,145,40,230,36,165,36,197,33,176,102,96,
201,160,176,239,168,16,236,201,141,240,90,201,138,59,97,136,208,201,198,36,16,232,165,33,133,36,198,36,165,34,197,37,
176,11,198,37,25,28,7,248,0,72,32,36,252,32,158,252,160,0,104,105,0,197,35,144,240,176,202,165,34,133,37,160,
0,132,36,240,228,169,0,133,36,230,55,62,55,16,182,198,37,25,29,7,248,25,6,7,248,56,72,233,1,208,252,104,
59,129,246,96,230,66,208,2,230,67,165,60,197,62,165,61,229,63,230,60,55,6,61,52,125,244,59,18,25,13,7,248,
230,78,208,2,230,79,44,0,192,16,245,145,40,173,0,192,44,16,192,96,25,10,7,248,254,96,165,50,72,169,255,133,
50,189,0,2,32,237,253,104,55,129,201,136,240,29,201,152,240,10,224,248,144,3,32,58,255,232,208,19,169,220,55,21,
25,10,7,248,254,25,30,7,248,59,27,0,72,52,162,88,32,229,253,104,41,15,9,176,201,186,144,2,105,6,108,54,
0,201,160,144,2,37,50,132,53,72,32,120,251,104,164,53,52,49,47,64,52,10,5,52,11,24,177,60,145,66,32,180,
252,144,247,52,190,97,59,1,160,63,208,2,160,255,132,50,52,98,82,62,162,56,160,27,208,8,55,130,54,160,240,165,
62,41,15,240,6,9,192,160,0,240,2,169,253,148,0,149,1,96,234,234,76,0,224,52,30,115,59,29,59,13,169,135,
76,237,253,165,72,72,165,69,166,70,164,71,52,110,22,52,62,27,59,30,59,14,245,3,251,3,98,250,98,250
];

File diff suppressed because one or more lines are too long

View File

@ -8,6 +8,22 @@ importScripts("cc65.js");
importScripts("ca65.js");
importScripts("ld65.js");
// shim out window and document objects for security
// https://github.com/mbostock/d3/issues/1053
var noop = function() { return new Function(); };
var window = noop();
window.CSSStyleDeclaration = noop();
window.CSSStyleDeclaration.setProperty = noop();
window.Element = noop();
window.Element.setAttribute = noop();
window.Element.setAttributeNS = noop();
window.navigator = noop();
var document = noop();
document.documentElement = noop();
document.documentElement.style = noop();
// load filesystems for CC65 and others asynchronously
var fsMeta, fsBlob;
{
var xhr = new XMLHttpRequest();
@ -23,6 +39,7 @@ var fsMeta, fsBlob;
console.log("Loaded filesystem", fsMeta.files.length, 'files', fsBlob.size, 'bytes');
}
// mount the filesystem at /share
function setupFS(FS) {
FS.mkdir('/share');
FS.mount(FS.filesystems['WORKERFS'], {
@ -30,21 +47,7 @@ function setupFS(FS) {
}, '/share');
}
// shim out window and document objects
// https://github.com/mbostock/d3/issues/1053
var noop = function() { return new Function(); };
var window = noop();
window.CSSStyleDeclaration = noop();
window.CSSStyleDeclaration.setProperty = noop();
window.Element = noop();
window.Element.setAttribute = noop();
window.Element.setAttributeNS = noop();
window.navigator = noop();
var document = noop();
document.documentElement = noop();
document.documentElement.style = noop();
// main worker start
var DASM_MAIN_FILENAME = "main.a";
var DASM_PREAMBLE = "\tprocessor 6502\n";
@ -129,48 +132,81 @@ function assembleDASM(code) {
FS.writeFile(DASM_MAIN_FILENAME, DASM_PREAMBLE + code);
Module.callMain([DASM_MAIN_FILENAME, "-v3", "-la.lst"]);
var aout = FS.readFile("a.out");
//console.log(aout);
var alst = FS.readFile("a.lst", {'encoding':'utf8'});
//console.log(alst);
var listing = parseDASMListing(alst, unresolved);
return {exitstatus:Module.EXITSTATUS, output:aout.slice(2), listing:listing};
return {
exitstatus:Module.EXITSTATUS,
output:aout.slice(2),
listing:listing,
intermediate:{listing:alst},
};
}
// TODO: not quite done
function assembleACME(code) {
var re_usl = /(\w+)\s+0000\s+[?][?][?][?]/; // TODO: modify for acme
var unresolved = {};
// stderr
var re_err2 = /(Error|Warning) - File (.+?), line (\d+) ([^:]+) (.*)/;
var errors = [];
var errline = 0;
function match_fn(s) {
var matches = re_usl.exec(s);
var matches = re_err2.exec(s);
if (matches) {
unresolved[matches[1]] = 0;
errors.push({
line:1, // TODO: parseInt(matches[3]),
msg:matches[0] // TODO: matches[5]
});
}
}
var Module = ACME({
noInitialRun:true,
print:match_fn
print:match_fn,
printErr:match_fn
});
var FS = Module['FS'];
FS.writeFile("main.a", code);
Module.callMain(["-o", "a.out", "-r", "a.rpt", "-l", "a.sym", "--setpc", "24576", "main.a"]);
if (errors.length) {
return {listing:{errors:errors}};
}
var aout = FS.readFile("a.out");
var alst = FS.readFile("a.rpt", {'encoding':'utf8'}); // TODO
var asym = FS.readFile("a.sym", {'encoding':'utf8'}); // TODO
console.log("acme", code.length, "->", aout.length);
//console.log(aout);
console.log(alst); // TODO
console.log(asym); // TODO
var listing = parseDASMListing(alst, unresolved);
return {exitstatus:Module.EXITSTATUS, output:aout, listing:listing};
var listing = parseDASMListing(alst, {}); // TODO
return {
exitstatus:Module.EXITSTATUS,
output:aout,
listing:listing,
intermediate:{listing:alst, symbols:asym},
};
}
function compilePLASMA(code) {
// stdout
var outstr = "";
function out_fn(s) { outstr += s; outstr += "\n"; }
// stderr
var re_err1 = /\s*(\d+):.*/;
var re_err2 = /Error: (.*)/;
var errors = [];
var errline = 0;
function match_fn(s) {
var matches = re_err1.exec(s);
if (matches) {
errline = parseInt(matches[1]);
}
matches = re_err2.exec(s);
if (matches) {
errors.push({
line:errline,
msg:matches[1]
});
}
}
var Module = PLASM({
noInitialRun:true,
noFSInit:true,
print:out_fn
print:out_fn,
printErr:match_fn,
});
var FS = Module['FS'];
var i = 0;
@ -180,13 +216,20 @@ function compilePLASMA(code) {
);
FS.writeFile("main.pla", code);
Module.callMain(["-A"]);
//console.log("plasm", code.length, "->", outstr.length);
outstr = "INTERP = $e044\n" + outstr; // TODO
console.log(outstr); // TODO
if (errors.length) {
return {listing:{errors:errors}};
}
return assembleACME(outstr);
}
function parseCA65Listing(code, unresolved) {
function parseCA65Listing(code, mapfile) {
// CODE 00603E 00637C 00033F 00001
var mapMatch = /^CODE\s+([0-9A-F]+)/m.exec(mapfile);
var codeofs = 0x6000;
if (mapMatch) {
var codeofs = parseInt(mapMatch[1], 16);
}
// .dbg line, "main.c", 1
var dbgLineMatch = /([0-9a-fA-F]+)([r]?)\s+(\d+)\s+[.]dbg\s+line,\s+\S+,\s+(\d+)/;
var errors = [];
@ -199,7 +242,7 @@ function parseCA65Listing(code, unresolved) {
var linenum = parseInt(linem[4]);
lines.push({
line:linenum,
offset:offset + 0x6048, //TODO: use map file
offset:offset + codeofs,
insns:null
});
//console.log(linem, lastlinenum, lines[lines.length-1]);
@ -208,14 +251,14 @@ function parseCA65Listing(code, unresolved) {
return {lines:lines, errors:errors};
}
function assemblelinkCA65(code, platform) {
function assemblelinkCA65(code, platform, warnings) {
if (!platform)
platform = 'apple2'; // TODO
var objout, lstout;
{
var CA65 = ca65({
noInitialRun:true,
logReadFiles:true,
//logReadFiles:true,
print:print_fn,
printErr:print_fn,
//locateFile: function(s) { return "" + s; },
@ -229,7 +272,7 @@ function assemblelinkCA65(code, platform) {
}{
var LD65 = ld65({
noInitialRun:true,
logReadFiles:true,
//logReadFiles:true,
print:print_fn,
printErr:print_fn,
//locateFile: function(s) { return "" + s; },
@ -242,29 +285,49 @@ function assemblelinkCA65(code, platform) {
'-t', platform, '-o', 'main', '-m', 'main.map', 'main.o', platform+'.lib']);
var aout = FS.readFile("main", {encoding:'binary'});
var mapout = FS.readFile("main.map", {encoding:'utf8'});
// CODE 00603E 00637C 00033F 00001
console.log(lstout);
console.log(mapout);
return {exitstatus:LD65.EXITSTATUS, output:aout.slice(4), listing:parseCA65Listing(lstout)};
return {
exitstatus:LD65.EXITSTATUS,
output:aout.slice(4),
listing:parseCA65Listing(lstout, mapout),
intermediate:{listing:lstout, map:mapout},
};
}
}
function compileCC65(code, platform) {
if (!platform)
platform = 'apple2'; // TODO
// stderr
var re_err1 = /.*?(\d+).*?: (.+)/;
var errors = [];
var errline = 0;
function match_fn(s) {
var matches = re_err1.exec(s);
if (matches) {
errline = parseInt(matches[1]);
errors.push({
line:errline,
msg:matches[2]
});
}
}
var CC65 = cc65({
noInitialRun:true,
logReadFiles:true,
//logReadFiles:true,
print:print_fn,
printErr:print_fn,
printErr:match_fn,
//locateFile: function(s) { return "" + s; },
});
var FS = CC65['FS'];
setupFS(FS);
FS.writeFile("main.c", code, {encoding:'utf8'});
CC65.callMain(['-v', '-T', '-g', '-Cl', '-Oirs', '-I', '/share/include', '-t', platform, "main.c"]);
var asmout = FS.readFile("main.s", {encoding:'utf8'});
return assemblelinkCA65(asmout, platform);
CC65.callMain(['-v', '-T', '-g', /*'-Cl',*/ '-Oirs', '-I', '/share/include', '-t', platform, "main.c"]);
try {
var asmout = FS.readFile("main.s", {encoding:'utf8'});
return assemblelinkCA65(asmout, platform, errors);
} catch(e) {
return {listing:{errors:errors}};
}
}
var tools = {
@ -279,7 +342,6 @@ onmessage = function(e) {
var toolfn = tools[e.data.tool];
if (!toolfn) throw "no tool named " + e.data.tool;
var result = toolfn(code);
//console.log("RESULT", result);
if (result) {
postMessage(result);
}