better track the resulting javascript too.
This commit is contained in:
parent
a06a65bb95
commit
d2092d9189
12 changed files with 1265 additions and 0 deletions
79
16col/adf.js
Normal file
79
16col/adf.js
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
// Generated by CoffeeScript 1.7.1
|
||||
(function() {
|
||||
var __hasProp = {}.hasOwnProperty,
|
||||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
||||
|
||||
this.ImageTextModeADF = (function(_super) {
|
||||
var COLOR_INDEX;
|
||||
|
||||
__extends(ImageTextModeADF, _super);
|
||||
|
||||
COLOR_INDEX = [0, 1, 2, 3, 4, 5, 20, 7, 56, 57, 58, 59, 60, 61, 62, 63];
|
||||
|
||||
function ImageTextModeADF(options) {
|
||||
var k, v;
|
||||
ImageTextModeADF.__super__.constructor.apply(this, arguments);
|
||||
this.header = {
|
||||
version: 0
|
||||
};
|
||||
for (k in options) {
|
||||
if (!__hasProp.call(options, k)) continue;
|
||||
v = options[k];
|
||||
this[k] = v;
|
||||
}
|
||||
}
|
||||
|
||||
ImageTextModeADF.prototype.parse = function(content) {
|
||||
var attr, ch, i, x, y, _i, _ref;
|
||||
this.header.version = this.getByteAt(content, 0);
|
||||
this.parsePaletteData(content.substr(1, 192));
|
||||
this.parseFontData(content.substr(193, 4096));
|
||||
x = 0;
|
||||
y = 0;
|
||||
this.screen[y] = [];
|
||||
for (i = _i = 4289, _ref = content.length - 2; _i <= _ref; i = _i += 2) {
|
||||
ch = content.substr(i, 1);
|
||||
if (ch === "\x1a") {
|
||||
break;
|
||||
}
|
||||
attr = this.getByteAt(content, i + 1);
|
||||
this.screen[y][x] = {
|
||||
'ch': ch,
|
||||
'attr': attr
|
||||
};
|
||||
x++;
|
||||
if (x === 80) {
|
||||
x = 0;
|
||||
y++;
|
||||
this.screen[y] = [];
|
||||
}
|
||||
}
|
||||
if (this.screen[y].length === 0) {
|
||||
return this.screen.pop();
|
||||
}
|
||||
};
|
||||
|
||||
ImageTextModeADF.prototype.parsePaletteData = function(data) {
|
||||
var b, colors, g, i, j, r, _i, _len;
|
||||
colors = [];
|
||||
for (_i = 0, _len = COLOR_INDEX.length; _i < _len; _i++) {
|
||||
i = COLOR_INDEX[_i];
|
||||
j = i * 3;
|
||||
r = this.getByteAt(data, j);
|
||||
r = r << 2 | r >> 4;
|
||||
g = this.getByteAt(data, j + 1);
|
||||
g = g << 2 | g >> 4;
|
||||
b = this.getByteAt(data, j + 2);
|
||||
b = b << 2 | b >> 4;
|
||||
colors.push([r, g, b]);
|
||||
}
|
||||
return this.palette = new ImageTextModePalette({
|
||||
colors: colors
|
||||
});
|
||||
};
|
||||
|
||||
return ImageTextModeADF;
|
||||
|
||||
})(this.ImageTextMode);
|
||||
|
||||
}).call(this);
|
||||
266
16col/ansi.js
Normal file
266
16col/ansi.js
Normal file
|
|
@ -0,0 +1,266 @@
|
|||
// Generated by CoffeeScript 1.7.1
|
||||
(function() {
|
||||
var ANSI_BG, ANSI_BG_INTENSE, ANSI_CSI, ANSI_CUR_DOWN, ANSI_ESC, ANSI_FG, ANSI_FG_INTENSE, ANSI_RESET, ANSI_RETURN, ANSI_SEP, ANSI_TEXT_PROP;
|
||||
|
||||
ANSI_ESC = String.fromCharCode(0x1b);
|
||||
|
||||
ANSI_CSI = ANSI_ESC + '[';
|
||||
|
||||
ANSI_TEXT_PROP = 'm';
|
||||
|
||||
ANSI_RESET = '0';
|
||||
|
||||
ANSI_FG = '3';
|
||||
|
||||
ANSI_BG = '4';
|
||||
|
||||
ANSI_FG_INTENSE = '9';
|
||||
|
||||
ANSI_BG_INTENSE = '10';
|
||||
|
||||
ANSI_CUR_DOWN = 'B';
|
||||
|
||||
ANSI_SEP = ';';
|
||||
|
||||
ANSI_RETURN = 'A';
|
||||
|
||||
({
|
||||
write: function() {
|
||||
var attr, content, max_x, pixel, prevattr, x, y, _i, _j, _ref, _ref1;
|
||||
content = "" + ANSI_CSI + "2J";
|
||||
for (y = _i = 0, _ref = this.screen.length; 0 <= _ref ? _i < _ref : _i > _ref; y = 0 <= _ref ? ++_i : --_i) {
|
||||
if (this.screen[y] == null) {
|
||||
content += "\n";
|
||||
}
|
||||
if (this.screen[y] == null) {
|
||||
continue;
|
||||
}
|
||||
for (x = _j = 0, _ref1 = this.getWidth(); 0 <= _ref1 ? _j < _ref1 : _j > _ref1; x = 0 <= _ref1 ? ++_j : --_j) {
|
||||
pixel = this.screen[y][x];
|
||||
if (pixel == null) {
|
||||
pixel = {
|
||||
ch: ' ',
|
||||
attr: 7
|
||||
};
|
||||
}
|
||||
attr = this.gen_args(pixel.attr);
|
||||
if (attr !== prevattr) {
|
||||
content += "" + ANSI_CSI + "0;" + attr + ANSI_TEXT_PROP;
|
||||
prevattr = attr;
|
||||
}
|
||||
content += pixel.ch != null ? pixel.ch : ' ';
|
||||
max_x = x;
|
||||
}
|
||||
}
|
||||
content += "" + ANSI_CSI + "0m";
|
||||
return this.toBinaryArray(content);
|
||||
},
|
||||
gen_args: function(attr) {
|
||||
var a, attrs, bg, bl, fg, intense, _i, _len, _ref;
|
||||
fg = 30 + (attr & 7);
|
||||
bg = 40 + ((attr & 112) >> 4);
|
||||
bl = attr & 128 ? 5 : '';
|
||||
intense = attr & 8 ? 1 : '';
|
||||
_ref = [fg, bg, bl, intense];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
a = _ref[_i];
|
||||
if (a !== '') {
|
||||
attrs = a;
|
||||
}
|
||||
}
|
||||
return [fg, bg, bl, intense].join(";");
|
||||
},
|
||||
parse: function(content) {
|
||||
var arg, args, ch, i, _i, _j, _k, _l, _len, _m, _n, _o, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _results;
|
||||
this.screen = [];
|
||||
this.state = 0;
|
||||
this.x = 0;
|
||||
this.y = 0;
|
||||
this.save_x = 0;
|
||||
this.save_y = 0;
|
||||
this.attr = 7;
|
||||
this.argbuf = '';
|
||||
content = content.split('');
|
||||
_results = [];
|
||||
while (ch = content.shift()) {
|
||||
if (this.state === 0) {
|
||||
switch (ch) {
|
||||
case "\x1a":
|
||||
_results.push(this.state = 3);
|
||||
break;
|
||||
case "\x1b":
|
||||
_results.push(this.state = 1);
|
||||
break;
|
||||
case "\n":
|
||||
this.x = 0;
|
||||
_results.push(this.y++);
|
||||
break;
|
||||
case "\r":
|
||||
break;
|
||||
case "\t":
|
||||
i = (this.x + 1) % this.tabstop;
|
||||
_results.push((function() {
|
||||
var _results1;
|
||||
_results1 = [];
|
||||
while (i-- > 0) {
|
||||
_results1.push(this.putpixel(' '));
|
||||
}
|
||||
return _results1;
|
||||
}).call(this));
|
||||
break;
|
||||
default:
|
||||
_results.push(this.putpixel(ch));
|
||||
}
|
||||
} else if (this.state === 1) {
|
||||
if (ch !== "[") {
|
||||
this.putpixel("\x1b");
|
||||
this.putpixel("[");
|
||||
_results.push(this.state = 0);
|
||||
} else {
|
||||
_results.push(this.state = 2);
|
||||
}
|
||||
} else if (this.state === 2) {
|
||||
if (ch.match('[A-Za-z]')) {
|
||||
args = (function() {
|
||||
var _i, _len, _ref, _results1;
|
||||
_ref = this.argbuf.split(';');
|
||||
_results1 = [];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
i = _ref[_i];
|
||||
_results1.push(parseInt(i));
|
||||
}
|
||||
return _results1;
|
||||
}).call(this);
|
||||
switch (ch) {
|
||||
case "m":
|
||||
for (_i = 0, _len = args.length; _i < _len; _i++) {
|
||||
arg = args[_i];
|
||||
if (arg === 0) {
|
||||
this.attr = 7;
|
||||
} else if (arg === 1) {
|
||||
this.attr |= 8;
|
||||
} else if (arg === 5) {
|
||||
this.attr |= 128;
|
||||
} else if ((30 <= arg && arg <= 37)) {
|
||||
this.attr &= 248;
|
||||
this.attr |= arg - 30;
|
||||
} else if ((40 <= arg && arg <= 47)) {
|
||||
this.attr &= 143;
|
||||
this.attr |= (arg - 40) << 4;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "H":
|
||||
case "f":
|
||||
this.y = (args[0] || 1) - 1;
|
||||
this.x = (args[1] || 1) - 1;
|
||||
if (this.y < 0) {
|
||||
this.y = 0;
|
||||
}
|
||||
if (this.x < 0) {
|
||||
this.x = 0;
|
||||
}
|
||||
break;
|
||||
case "A":
|
||||
this.y -= args[0] || 1;
|
||||
if (this.y < 0) {
|
||||
this.y = 0;
|
||||
}
|
||||
break;
|
||||
case "B":
|
||||
this.y += args[0] || 1;
|
||||
break;
|
||||
case "C":
|
||||
this.x += args[0] || 1;
|
||||
break;
|
||||
case "D":
|
||||
this.x -= args[0] || 1;
|
||||
if (this.x < 0) {
|
||||
this.x = 0;
|
||||
}
|
||||
break;
|
||||
case "E":
|
||||
this.y += args[0] || 1;
|
||||
this.x = 0;
|
||||
break;
|
||||
case "F":
|
||||
this.y -= args[0] || 1;
|
||||
if (this.y > 0) {
|
||||
this.y = 0;
|
||||
}
|
||||
this.x = 0;
|
||||
break;
|
||||
case "G":
|
||||
this.x = (args[0] || 1) - 1;
|
||||
break;
|
||||
case "s":
|
||||
this.save_x = this.x;
|
||||
this.save_y = this.y;
|
||||
break;
|
||||
case "u":
|
||||
this.x = this.save_x;
|
||||
this.y = this.save_y;
|
||||
break;
|
||||
case "J":
|
||||
if (args.length === 0 || args[0] === 0) {
|
||||
for (i = _j = _ref = this.y + 1, _ref1 = screen.length - 1; _ref <= _ref1 ? _j <= _ref1 : _j >= _ref1; i = _ref <= _ref1 ? ++_j : --_j) {
|
||||
this.screen[i] = null;
|
||||
}
|
||||
for (i = _k = _ref2 = this.x, _ref3 = screen[this.y].length - 1; _ref2 <= _ref3 ? _k <= _ref3 : _k >= _ref3; i = _ref2 <= _ref3 ? ++_k : --_k) {
|
||||
this.screen[this.y][i] = null;
|
||||
}
|
||||
} else if (args[0] === 1) {
|
||||
for (i = _l = 0, _ref4 = this.y - 1; 0 <= _ref4 ? _l <= _ref4 : _l >= _ref4; i = 0 <= _ref4 ? ++_l : --_l) {
|
||||
this.screen[i] = null;
|
||||
}
|
||||
for (i = _m = 0, _ref5 = this.x; 0 <= _ref5 ? _m <= _ref5 : _m >= _ref5; i = 0 <= _ref5 ? ++_m : --_m) {
|
||||
this.screen[this.y][i] = null;
|
||||
}
|
||||
} else if (args[0] === 2) {
|
||||
this.x = 0;
|
||||
this.y = 0;
|
||||
this.screen = [];
|
||||
}
|
||||
break;
|
||||
case "K":
|
||||
if (args.length === 0 || args[0] === 0) {
|
||||
for (i = _n = _ref6 = this.x, _ref7 = this.screen[this.y].length - 1; _ref6 <= _ref7 ? _n <= _ref7 : _n >= _ref7; i = _ref6 <= _ref7 ? ++_n : --_n) {
|
||||
this.screen[this.y][i] = null;
|
||||
}
|
||||
} else if (args[0] === 1) {
|
||||
for (i = _o = 0, _ref8 = this.x; 0 <= _ref8 ? _o <= _ref8 : _o >= _ref8; i = 0 <= _ref8 ? ++_o : --_o) {
|
||||
this.screen[this.y][i] = null;
|
||||
}
|
||||
} else if (args[0] === 2) {
|
||||
this.screen[this.y] = null;
|
||||
}
|
||||
}
|
||||
this.argbuf = '';
|
||||
_results.push(this.state = 0);
|
||||
} else {
|
||||
_results.push(this.argbuf += ch);
|
||||
}
|
||||
} else if (this.state === 3) {
|
||||
break;
|
||||
} else {
|
||||
_results.push(this.state = 0);
|
||||
}
|
||||
}
|
||||
return _results;
|
||||
},
|
||||
putpixel: function(ch) {
|
||||
if (this.screen[this.y] == null) {
|
||||
this.screen[this.y] = [];
|
||||
}
|
||||
this.screen[this.y][this.x] = {
|
||||
ch: ch,
|
||||
attr: this.attr
|
||||
};
|
||||
if (++this.x >= this.linewrap) {
|
||||
this.x = 0;
|
||||
return this.y++;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
143
16col/avatar.js
Normal file
143
16col/avatar.js
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
// Generated by CoffeeScript 1.7.1
|
||||
(function() {
|
||||
var __hasProp = {}.hasOwnProperty,
|
||||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
||||
|
||||
this.ImageTextModeAVATAR = (function(_super) {
|
||||
__extends(ImageTextModeAVATAR, _super);
|
||||
|
||||
function ImageTextModeAVATAR(options) {
|
||||
var k, v;
|
||||
ImageTextModeAVATAR.__super__.constructor.apply(this, arguments);
|
||||
this.tabstop = 8;
|
||||
this.linewrap = 80;
|
||||
for (k in options) {
|
||||
if (!__hasProp.call(options, k)) continue;
|
||||
v = options[k];
|
||||
this[k] = v;
|
||||
}
|
||||
}
|
||||
|
||||
ImageTextModeAVATAR.prototype.parse = function(content) {
|
||||
var c, ch, i, _results;
|
||||
this.screen = [];
|
||||
this.x = 0;
|
||||
this.y = 0;
|
||||
this.attr = 3;
|
||||
content = content.split('');
|
||||
_results = [];
|
||||
while (ch = content.shift()) {
|
||||
if (ch === "\x1a") {
|
||||
break;
|
||||
} else if (ch === "\n") {
|
||||
this.x = 0;
|
||||
_results.push(this.y++);
|
||||
} else if (ch === "\r") {
|
||||
continue;
|
||||
} else if (ch === "\t") {
|
||||
i = (this.x + 1) % this.tabstop;
|
||||
_results.push((function() {
|
||||
var _results1;
|
||||
_results1 = [];
|
||||
while (i-- > 0) {
|
||||
_results1.push(this.putpixel(' '));
|
||||
}
|
||||
return _results1;
|
||||
}).call(this));
|
||||
} else if (ch.charCodeAt(0) === 12) {
|
||||
this.screen = [];
|
||||
this.attr = 3;
|
||||
_results.push(this.insert = false);
|
||||
} else if (ch.charCodeAt(0) === 25) {
|
||||
ch = content.shift();
|
||||
i = content.shift().charCodeAt(0);
|
||||
_results.push((function() {
|
||||
var _results1;
|
||||
_results1 = [];
|
||||
while (i-- > 0) {
|
||||
_results1.push(this.putpixel(ch));
|
||||
}
|
||||
return _results1;
|
||||
}).call(this));
|
||||
} else if (ch.charCodeAt(0) === 22) {
|
||||
c = content.shift().charCodeAt(0);
|
||||
switch (c) {
|
||||
case 1:
|
||||
_results.push(this.attr = content.shift().charCodeAt(0) & 0x7f);
|
||||
break;
|
||||
case 2:
|
||||
_results.push(this.attr |= 0x80);
|
||||
break;
|
||||
case 3:
|
||||
this.y--;
|
||||
if (this.y < 0) {
|
||||
_results.push(this.y = 0);
|
||||
} else {
|
||||
_results.push(void 0);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
_results.push(this.y++);
|
||||
break;
|
||||
case 5:
|
||||
this.x--;
|
||||
if (this.x < 0) {
|
||||
_results.push(this.x = 0);
|
||||
} else {
|
||||
_results.push(void 0);
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
_results.push(this.x++);
|
||||
break;
|
||||
case 7:
|
||||
_results.push((function() {
|
||||
var _i, _ref, _ref1, _results1;
|
||||
_results1 = [];
|
||||
for (i = _i = _ref = this.x, _ref1 = screen[this.y].length - 1; _ref <= _ref1 ? _i <= _ref1 : _i >= _ref1; i = _ref <= _ref1 ? ++_i : --_i) {
|
||||
_results1.push(this.screen[this.y][i] = null);
|
||||
}
|
||||
return _results1;
|
||||
}).call(this));
|
||||
break;
|
||||
case 8:
|
||||
this.y = content.shift().charCodeAt(0) - 1;
|
||||
this.x = content.shift().charCodeAt(0) - 1;
|
||||
if (this.y < 0) {
|
||||
this.y = 0;
|
||||
}
|
||||
if (this.x < 0) {
|
||||
_results.push(this.x = 0);
|
||||
} else {
|
||||
_results.push(void 0);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
_results.push(void 0);
|
||||
}
|
||||
} else {
|
||||
_results.push(this.putpixel(ch));
|
||||
}
|
||||
}
|
||||
return _results;
|
||||
};
|
||||
|
||||
ImageTextModeAVATAR.prototype.putpixel = function(ch) {
|
||||
if (this.screen[this.y] == null) {
|
||||
this.screen[this.y] = [];
|
||||
}
|
||||
this.screen[this.y][this.x] = {
|
||||
ch: ch,
|
||||
attr: this.attr
|
||||
};
|
||||
if (++this.x >= this.linewrap) {
|
||||
this.x = 0;
|
||||
return this.y++;
|
||||
}
|
||||
};
|
||||
|
||||
return ImageTextModeAVATAR;
|
||||
|
||||
})(this.ImageTextMode);
|
||||
|
||||
}).call(this);
|
||||
51
16col/bin.js
Normal file
51
16col/bin.js
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
// Generated by CoffeeScript 1.7.1
|
||||
(function() {
|
||||
var __hasProp = {}.hasOwnProperty,
|
||||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
||||
|
||||
this.ImageTextModeBin = (function(_super) {
|
||||
__extends(ImageTextModeBin, _super);
|
||||
|
||||
function ImageTextModeBin(options) {
|
||||
var k, v;
|
||||
ImageTextModeBin.__super__.constructor.apply(this, arguments);
|
||||
this.linewrap = 160;
|
||||
for (k in options) {
|
||||
if (!__hasProp.call(options, k)) continue;
|
||||
v = options[k];
|
||||
this[k] = v;
|
||||
}
|
||||
}
|
||||
|
||||
ImageTextModeBin.prototype.parse = function(content) {
|
||||
var attr, ch, i, x, y, _i, _ref;
|
||||
x = 0;
|
||||
y = 0;
|
||||
this.screen[y] = [];
|
||||
for (i = _i = 0, _ref = content.length - 2; _i <= _ref; i = _i += 2) {
|
||||
ch = content.substr(i, 1);
|
||||
if (ch === "\x1a") {
|
||||
break;
|
||||
}
|
||||
attr = this.getByteAt(content, i + 1);
|
||||
this.screen[y][x] = {
|
||||
'ch': ch,
|
||||
'attr': attr
|
||||
};
|
||||
x++;
|
||||
if (x === this.linewrap) {
|
||||
x = 0;
|
||||
y++;
|
||||
this.screen[y] = [];
|
||||
}
|
||||
}
|
||||
if (this.screen[y].length === 0) {
|
||||
return this.screen.pop();
|
||||
}
|
||||
};
|
||||
|
||||
return ImageTextModeBin;
|
||||
|
||||
})(this.ImageTextMode);
|
||||
|
||||
}).call(this);
|
||||
5
16col/fonts.js
Normal file
5
16col/fonts.js
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
// Generated by CoffeeScript 1.7.1
|
||||
(function() {
|
||||
|
||||
|
||||
}).call(this);
|
||||
80
16col/idf.js
Normal file
80
16col/idf.js
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
// Generated by CoffeeScript 1.7.1
|
||||
(function() {
|
||||
var __hasProp = {}.hasOwnProperty,
|
||||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
||||
|
||||
this.ImageTextModeIDF = (function(_super) {
|
||||
__extends(ImageTextModeIDF, _super);
|
||||
|
||||
function ImageTextModeIDF(options) {
|
||||
var k, v;
|
||||
ImageTextModeIDF.__super__.constructor.apply(this, arguments);
|
||||
this.header = {
|
||||
x0: 0,
|
||||
x1: 0,
|
||||
y0: 0,
|
||||
y1: 0
|
||||
};
|
||||
for (k in options) {
|
||||
if (!__hasProp.call(options, k)) continue;
|
||||
v = options[k];
|
||||
this[k] = v;
|
||||
}
|
||||
}
|
||||
|
||||
ImageTextModeIDF.prototype.parse = function(content) {
|
||||
var attr, buffer, ch, eodata, headerData, i, info, len, offset, x, y, _i;
|
||||
headerData = content.substr(0, 12);
|
||||
if (headerData.length !== 12 || !headerData.match('^\x041.4')) {
|
||||
throw new Error('File is not an IDF');
|
||||
}
|
||||
this.header.x0 = this.unpackShort(headerData.substr(4, 2));
|
||||
this.header.y0 = this.unpackShort(headerData.substr(6, 2));
|
||||
this.header.x1 = this.unpackShort(headerData.substr(8, 2));
|
||||
this.header.y1 = this.unpackShort(headerData.substr(10, 2));
|
||||
eodata = content.length - 48 - 4096;
|
||||
if (content.substr(content.length - 128, 5) === 'SAUCE') {
|
||||
eodata -= 128;
|
||||
}
|
||||
this.parseFontData(content.substr(eodata, 4096));
|
||||
this.parsePaletteData(content.substr(eodata + 4096, 48));
|
||||
y = 0;
|
||||
x = 0;
|
||||
this.screen[y] = [];
|
||||
offset = 12;
|
||||
while (offset < eodata) {
|
||||
buffer = content.substr(offset, 2);
|
||||
info = this.unpackShort(buffer);
|
||||
offset += 2;
|
||||
len = 1;
|
||||
if (info === 1) {
|
||||
len = this.unpackShort(content.substr(offset, 2)) & 255;
|
||||
offset += 2;
|
||||
buffer = content.substr(offset, 2);
|
||||
offset += 2;
|
||||
}
|
||||
ch = buffer.substr(0, 1);
|
||||
attr = this.getByteAt(buffer, 1);
|
||||
for (i = _i = 1; 1 <= len ? _i <= len : _i >= len; i = 1 <= len ? ++_i : --_i) {
|
||||
this.screen[y][x] = {
|
||||
'ch': ch,
|
||||
'attr': attr
|
||||
};
|
||||
x++;
|
||||
if (x > this.header.x1) {
|
||||
x = 0;
|
||||
y++;
|
||||
this.screen[y] = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.screen[y].length === 0) {
|
||||
return this.screen.pop();
|
||||
}
|
||||
};
|
||||
|
||||
return ImageTextModeIDF;
|
||||
|
||||
})(this.ImageTextMode);
|
||||
|
||||
}).call(this);
|
||||
143
16col/imgtxtmode.js
Normal file
143
16col/imgtxtmode.js
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
// Generated by CoffeeScript 1.7.1
|
||||
(function() {
|
||||
var __hasProp = {}.hasOwnProperty;
|
||||
|
||||
this.VERSION = '0.01';
|
||||
|
||||
({
|
||||
constructor: function(options) {
|
||||
var k, v, _results;
|
||||
this.screen = [];
|
||||
this.palette = new ImageTextModePaletteVGA();
|
||||
this.font = new ImageTextModeFont8x16();
|
||||
_results = [];
|
||||
for (k in options) {
|
||||
if (!__hasProp.call(options, k)) continue;
|
||||
v = options[k];
|
||||
_results.push(this[k] = v);
|
||||
}
|
||||
return _results;
|
||||
},
|
||||
parseUrl: function(url) {
|
||||
var content, req;
|
||||
req = new XMLHttpRequest();
|
||||
req.open('GET', url, false);
|
||||
req.overrideMimeType('text/plain; charset=x-user-defined');
|
||||
req.send(null);
|
||||
content = req.status === 200 || req.status === 0 ? req.responseText : '';
|
||||
return this.parse(content);
|
||||
},
|
||||
unpackShort: function(data) {
|
||||
var shrt;
|
||||
shrt = (this.getByteAt(data, 1) << 8) + this.getByteAt(data, 0);
|
||||
if (shrt < 0) {
|
||||
shrt += 65536;
|
||||
}
|
||||
return shrt;
|
||||
},
|
||||
unpackLong: function(data) {
|
||||
var lng;
|
||||
lng = (((this.getByteAt(data, 0) << 8) + this.getByteAt(data, 1) << 8) + this.getByteAt(data, 2) << 8) + this.getByteAt(data, 3);
|
||||
if (lng < 0) {
|
||||
lng += 4294967296;
|
||||
}
|
||||
return lng;
|
||||
},
|
||||
getByteAt: function(data, offset) {
|
||||
return data.charCodeAt(offset) & 0xFF;
|
||||
},
|
||||
getHeight: function() {
|
||||
return this.screen.length;
|
||||
},
|
||||
parsePaletteData: function(data) {
|
||||
var b, colors, g, i, r, _i;
|
||||
colors = [];
|
||||
for (i = _i = 0; _i <= 45; i = _i += 3) {
|
||||
r = this.getByteAt(data, i);
|
||||
r = r << 2 | r >> 4;
|
||||
g = this.getByteAt(data, i + 1);
|
||||
g = g << 2 | g >> 4;
|
||||
b = this.getByteAt(data, i + 2);
|
||||
b = b << 2 | b >> 4;
|
||||
colors.push([r, g, b]);
|
||||
}
|
||||
return this.palette = new ImageTextModePalette({
|
||||
colors: colors
|
||||
});
|
||||
},
|
||||
parseFontData: function(data, height) {
|
||||
var chars, chr, i, j, _i, _j, _ref;
|
||||
if (height == null) {
|
||||
height = 16;
|
||||
}
|
||||
chars = [];
|
||||
for (i = _i = 0, _ref = data.length / height; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) {
|
||||
chr = [];
|
||||
for (j = _j = 0; 0 <= height ? _j < height : _j > height; j = 0 <= height ? ++_j : --_j) {
|
||||
chr.push(this.getByteAt(data, i * height + j));
|
||||
}
|
||||
chars.push(chr);
|
||||
}
|
||||
return this.font = new ImageTextModeFont({
|
||||
chars: chars,
|
||||
height: height
|
||||
});
|
||||
},
|
||||
renderCanvas: function(canvasElem) {
|
||||
var bg, canvas, chr, ctx, curfillstyle, cx, cy, fg, h, i, j, line, pixel, px, py, w, _i, _j, _k, _l, _len, _ref, _ref1, _ref2;
|
||||
w = this.getWidth() * this.font.width;
|
||||
h = this.getHeight() * this.font.height;
|
||||
canvas = document.createElement('canvas');
|
||||
canvas.setAttribute('width', w);
|
||||
canvas.setAttribute('height', h);
|
||||
ctx = canvas.getContext('2d');
|
||||
for (cy = _i = 0, _ref = this.screen.length; 0 <= _ref ? _i < _ref : _i > _ref; cy = 0 <= _ref ? ++_i : --_i) {
|
||||
if (this.screen[cy] != null) {
|
||||
for (cx = _j = 0, _ref1 = this.screen[cy].length; 0 <= _ref1 ? _j < _ref1 : _j > _ref1; cx = 0 <= _ref1 ? ++_j : --_j) {
|
||||
pixel = this.screen[cy][cx];
|
||||
curfillstyle = null;
|
||||
if (pixel != null) {
|
||||
if (pixel.attr != null) {
|
||||
fg = pixel.attr & 15;
|
||||
bg = (pixel.attr & 240) >> 4;
|
||||
} else {
|
||||
fg = pixel.fg;
|
||||
bg = pixel.bg;
|
||||
}
|
||||
px = cx * this.font.width;
|
||||
py = cy * this.font.height;
|
||||
ctx.fillStyle = this.palette.toRgbaString(this.palette.colors[bg]);
|
||||
ctx.fillRect(px, py, this.font.width, this.font.height);
|
||||
ctx.fillStyle = this.palette.toRgbaString(this.palette.colors[fg]);
|
||||
chr = this.font.chars[pixel.ch.charCodeAt(0) & 0xff];
|
||||
i = 0;
|
||||
for (_k = 0, _len = chr.length; _k < _len; _k++) {
|
||||
line = chr[_k];
|
||||
for (j = _l = 0, _ref2 = this.font.width; 0 <= _ref2 ? _l < _ref2 : _l > _ref2; j = 0 <= _ref2 ? ++_l : --_l) {
|
||||
if (line & (1 << this.font.width - 1 - j)) {
|
||||
ctx.fillRect(px + j, py + i, 1, 1);
|
||||
}
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
canvasElem.setAttribute('width', w);
|
||||
canvasElem.setAttribute('height', h);
|
||||
ctx = canvasElem.getContext('2d');
|
||||
return ctx.drawImage(canvas, 0, 0);
|
||||
},
|
||||
toBinaryArray: function(str) {
|
||||
var buf, bufView, i, _i, _ref;
|
||||
buf = new ArrayBuffer(str.length * 2);
|
||||
bufView = new Uint8Array(buf);
|
||||
for (i = _i = 0, _ref = str.length; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) {
|
||||
bufView[i] = str.charCodeAt(i);
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
22
16col/pallette.js
Normal file
22
16col/pallette.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
// Generated by CoffeeScript 1.7.1
|
||||
(function() {
|
||||
var __hasProp = {}.hasOwnProperty;
|
||||
|
||||
({
|
||||
constructor: function(options) {
|
||||
var k, v, _results;
|
||||
this.colors = [];
|
||||
_results = [];
|
||||
for (k in options) {
|
||||
if (!__hasProp.call(options, k)) continue;
|
||||
v = options[k];
|
||||
_results.push(this[k] = v);
|
||||
}
|
||||
return _results;
|
||||
},
|
||||
toRgbaString: function(color) {
|
||||
return 'rgba(' + color.join(',') + ',1)';
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
119
16col/pcboard.js
Normal file
119
16col/pcboard.js
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
// Generated by CoffeeScript 1.7.1
|
||||
(function() {
|
||||
var __hasProp = {}.hasOwnProperty,
|
||||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
||||
|
||||
this.ImageTextModePCBoard = (function(_super) {
|
||||
__extends(ImageTextModePCBoard, _super);
|
||||
|
||||
function ImageTextModePCBoard(options) {
|
||||
var k, v;
|
||||
ImageTextModePCBoard.__super__.constructor.apply(this, arguments);
|
||||
this.tabstop = 8;
|
||||
this.linewrap = 80;
|
||||
this.codes = {
|
||||
POFF: '',
|
||||
WAIT: ''
|
||||
};
|
||||
for (k in options) {
|
||||
if (!__hasProp.call(options, k)) continue;
|
||||
v = options[k];
|
||||
this[k] = v;
|
||||
}
|
||||
}
|
||||
|
||||
ImageTextModePCBoard.prototype.parse = function(content) {
|
||||
var ch, code, i, key, val, _i, _j, _ref, _results;
|
||||
this.screen = [];
|
||||
this.state = 0;
|
||||
this.x = 0;
|
||||
this.y = 0;
|
||||
this.attr = 7;
|
||||
_ref = this.codes;
|
||||
for (key in _ref) {
|
||||
val = _ref[key];
|
||||
code = new RegExp('@' + key + '@', 'g');
|
||||
content.replace(code, val);
|
||||
}
|
||||
content = content.split('');
|
||||
_results = [];
|
||||
while (ch = content.shift()) {
|
||||
if (this.state === 0) {
|
||||
switch (ch) {
|
||||
case "\x1a":
|
||||
_results.push(this.state = 2);
|
||||
break;
|
||||
case '@':
|
||||
_results.push(this.state = 1);
|
||||
break;
|
||||
case "\n":
|
||||
this.x = 0;
|
||||
_results.push(this.y++);
|
||||
break;
|
||||
case "\r":
|
||||
break;
|
||||
case "\t":
|
||||
i = (this.x + 1) % this.tabstop;
|
||||
_results.push((function() {
|
||||
var _results1;
|
||||
_results1 = [];
|
||||
while (i-- > 0) {
|
||||
_results1.push(this.putpixel(' '));
|
||||
}
|
||||
return _results1;
|
||||
}).call(this));
|
||||
break;
|
||||
default:
|
||||
_results.push(this.putpixel(ch));
|
||||
}
|
||||
} else if (this.state === 1) {
|
||||
if (ch === 'X') {
|
||||
this.attr = (parseInt(content.shift(), 16) << 4) + parseInt(content.shift(), 16);
|
||||
} else if (ch + content.slice(0, 3).join('') === 'CLS@') {
|
||||
for (_i = 1; _i <= 3; _i++) {
|
||||
content.shift();
|
||||
}
|
||||
this.screen = [];
|
||||
} else if (ch + content.slice(0, 3).join('') === 'POS:') {
|
||||
for (_j = 1; _j <= 3; _j++) {
|
||||
content.shift();
|
||||
}
|
||||
this.x = content.shift();
|
||||
if (content[0] !== '@') {
|
||||
this.x += content.shift();
|
||||
}
|
||||
this.x--;
|
||||
content.shift();
|
||||
} else {
|
||||
this.putpixel('@');
|
||||
this.putpixel(ch);
|
||||
}
|
||||
_results.push(this.state = 0);
|
||||
} else if (this.state === 2) {
|
||||
break;
|
||||
} else {
|
||||
_results.push(this.state = 0);
|
||||
}
|
||||
}
|
||||
return _results;
|
||||
};
|
||||
|
||||
ImageTextModePCBoard.prototype.putpixel = function(ch) {
|
||||
if (this.screen[this.y] == null) {
|
||||
this.screen[this.y] = [];
|
||||
}
|
||||
this.screen[this.y][this.x] = {
|
||||
ch: ch,
|
||||
attr: this.attr
|
||||
};
|
||||
if (++this.x >= this.linewrap) {
|
||||
this.x = 0;
|
||||
return this.y++;
|
||||
}
|
||||
};
|
||||
|
||||
return ImageTextModePCBoard;
|
||||
|
||||
})(this.ImageTextMode);
|
||||
|
||||
}).call(this);
|
||||
68
16col/sauce.js
Normal file
68
16col/sauce.js
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
// Generated by CoffeeScript 1.7.1
|
||||
(function() {
|
||||
({
|
||||
parseUrl: function(url) {
|
||||
var content, req;
|
||||
req = new XMLHttpRequest();
|
||||
req.open('GET', url, false);
|
||||
req.overrideMimeType('text/plain; charset=x-user-defined');
|
||||
req.send(null);
|
||||
content = req.status === 200 || req.status === 0 ? req.responseText : '';
|
||||
return this.parse(content);
|
||||
},
|
||||
parse: function(content) {
|
||||
var commentMarker, i, sauceMarker;
|
||||
sauceMarker = content.length - 128;
|
||||
if (content.substr(sauceMarker, 5) !== 'SAUCE') {
|
||||
return false;
|
||||
}
|
||||
this.id = 'SAUCE';
|
||||
this.version = content.substr(sauceMarker + 5, 2);
|
||||
this.title = content.substr(sauceMarker + 7, 35);
|
||||
this.author = content.substr(sauceMarker + 42, 20);
|
||||
this.group = content.substr(sauceMarker + 62, 20);
|
||||
this.date = content.substr(sauceMarker + 82, 8);
|
||||
this.fileSize = this.unpackLong(content.substr(sauceMarker + 90, 4));
|
||||
this.dataType = this.getByteAt(content.substr(sauceMarker + 94, 1));
|
||||
this.fileType = this.getByteAt(content.substr(sauceMarker + 95, 1));
|
||||
this.tinfo1 = this.unpackShort(content.substr(sauceMarker + 96, 2));
|
||||
this.tinfo2 = this.unpackShort(content.substr(sauceMarker + 98, 2));
|
||||
this.tinfo3 = this.unpackShort(content.substr(sauceMarker + 100, 2));
|
||||
this.tinfo4 = this.unpackShort(content.substr(sauceMarker + 102, 2));
|
||||
this.commentCount = this.getByteAt(content.substr(sauceMarker + 104, 1));
|
||||
this.flags = this.getByteAt(content.substr(sauceMarker + 105, 1));
|
||||
this.filler = content.substr(sauceMarker + 106, 22);
|
||||
commentMarker = sauceMarker - 5 - this.commentCount * 64;
|
||||
if (this.commentCount > 0 && content.substr(commentMarker, 5) === 'COMNT') {
|
||||
commentMarker += 5;
|
||||
this.comments = [];
|
||||
i = this.commentCount;
|
||||
while (i-- > 0) {
|
||||
this.comments.push(content.substr(commentMarker, 64));
|
||||
commentMarker += 64;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
unpackLong: function(data) {
|
||||
var lng;
|
||||
lng = (((this.getByteAt(data, 3) << 8) + this.getByteAt(data, 2) << 8) + this.getByteAt(data, 1) << 8) + this.getByteAt(data, 0);
|
||||
if (lng < 0) {
|
||||
lng += 4294967296;
|
||||
}
|
||||
return lng;
|
||||
},
|
||||
unpackShort: function(data) {
|
||||
var shrt;
|
||||
shrt = (this.getByteAt(data, 1) << 8) + this.getByteAt(data, 0);
|
||||
if (shrt < 0) {
|
||||
shrt += 65536;
|
||||
}
|
||||
return shrt;
|
||||
},
|
||||
getByteAt: function(data, offset) {
|
||||
return data.charCodeAt(offset) & 0xFF;
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
89
16col/tundra.js
Normal file
89
16col/tundra.js
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
// Generated by CoffeeScript 1.7.1
|
||||
(function() {
|
||||
var __hasProp = {}.hasOwnProperty,
|
||||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
||||
|
||||
this.ImageTextModeTundra = (function(_super) {
|
||||
__extends(ImageTextModeTundra, _super);
|
||||
|
||||
function ImageTextModeTundra(options) {
|
||||
var k, v;
|
||||
ImageTextModeTundra.__super__.constructor.apply(this, arguments);
|
||||
for (k in options) {
|
||||
if (!__hasProp.call(options, k)) continue;
|
||||
v = options[k];
|
||||
this[k] = v;
|
||||
}
|
||||
}
|
||||
|
||||
ImageTextModeTundra.prototype.parse = function(content) {
|
||||
var bg, ch, colors, command, fg, palidx, rgb, x, y, _i;
|
||||
colors = [[0, 0, 0]];
|
||||
palidx = 1;
|
||||
x = 0;
|
||||
y = 0;
|
||||
fg = 0;
|
||||
bg = 0;
|
||||
this.screen[y] = [];
|
||||
content = content.substr(8).split('');
|
||||
while (command = content.shift()) {
|
||||
if (command === "\x1a") {
|
||||
break;
|
||||
}
|
||||
command = command.charCodeAt(0);
|
||||
if (command === 1) {
|
||||
y = this.unpackLong(content.splice(0, 4).join(''));
|
||||
x = this.unpackLong(content.splice(0, 4).join(''));
|
||||
if (this.screen[y] == null) {
|
||||
this.screen[y] = [];
|
||||
}
|
||||
continue;
|
||||
}
|
||||
ch = null;
|
||||
if (command === 2) {
|
||||
ch = content.shift();
|
||||
rgb = this.unpackLong(content.splice(0, 4).join(''));
|
||||
fg = palidx++;
|
||||
colors.push([(rgb >> 16) & 0x000000ff, (rgb >> 8) & 0x000000ff, rgb & 0x000000ff]);
|
||||
} else if (command === 4) {
|
||||
ch = content.shift();
|
||||
rgb = this.unpackLong(content.splice(0, 4).join(''));
|
||||
bg = palidx++;
|
||||
colors.push([(rgb >> 16) & 0x000000ff, (rgb >> 8) & 0x000000ff, rgb & 0x000000ff]);
|
||||
} else if (command === 6) {
|
||||
ch = content.shift();
|
||||
fg = palidx++;
|
||||
bg = palidx++;
|
||||
for (_i = 0; _i <= 1; _i++) {
|
||||
rgb = this.unpackLong(content.splice(0, 4).join(''));
|
||||
colors.push([(rgb >> 16) & 0x000000ff, (rgb >> 8) & 0x000000ff, rgb & 0x000000ff]);
|
||||
}
|
||||
}
|
||||
if (ch == null) {
|
||||
ch = String.fromCharCode(command);
|
||||
}
|
||||
this.screen[y][x] = {
|
||||
'ch': ch,
|
||||
'fg': fg,
|
||||
'bg': bg
|
||||
};
|
||||
x++;
|
||||
if (x === 80) {
|
||||
x = 0;
|
||||
y++;
|
||||
this.screen[y] = [];
|
||||
}
|
||||
}
|
||||
if (this.screen[y].length === 0) {
|
||||
this.screen.pop();
|
||||
}
|
||||
return this.palette = new ImageTextModePalette({
|
||||
colors: colors
|
||||
});
|
||||
};
|
||||
|
||||
return ImageTextModeTundra;
|
||||
|
||||
})(this.ImageTextMode);
|
||||
|
||||
}).call(this);
|
||||
200
16col/xbin.js
Normal file
200
16col/xbin.js
Normal file
|
|
@ -0,0 +1,200 @@
|
|||
// Generated by CoffeeScript 1.7.1
|
||||
(function() {
|
||||
var __hasProp = {}.hasOwnProperty,
|
||||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
||||
|
||||
this.ImageTextModeXBin = (function(_super) {
|
||||
var ATTRIBUTE_COMPRESSION, CHARACTER_COMPRESSION, COMPRESSED, COMPRESSION_COUNTER, COMPRESSION_TYPE, FIVETWELVE_CHARS, FONT, FULL_COMPRESSION, NON_BLINK, NO_COMPRESSION, PALETTE;
|
||||
|
||||
__extends(ImageTextModeXBin, _super);
|
||||
|
||||
PALETTE = 1;
|
||||
|
||||
FONT = 2;
|
||||
|
||||
COMPRESSED = 4;
|
||||
|
||||
NON_BLINK = 8;
|
||||
|
||||
FIVETWELVE_CHARS = 16;
|
||||
|
||||
NO_COMPRESSION = 0;
|
||||
|
||||
CHARACTER_COMPRESSION = 64;
|
||||
|
||||
ATTRIBUTE_COMPRESSION = 128;
|
||||
|
||||
FULL_COMPRESSION = 192;
|
||||
|
||||
COMPRESSION_TYPE = 192;
|
||||
|
||||
COMPRESSION_COUNTER = 63;
|
||||
|
||||
function ImageTextModeXBin(options) {
|
||||
var k, v;
|
||||
ImageTextModeXBin.__super__.constructor.apply(this, arguments);
|
||||
this.header = {
|
||||
width: 0,
|
||||
height: 0,
|
||||
fontisze: 0,
|
||||
flags: 0
|
||||
};
|
||||
for (k in options) {
|
||||
if (!__hasProp.call(options, k)) continue;
|
||||
v = options[k];
|
||||
this[k] = v;
|
||||
}
|
||||
}
|
||||
|
||||
ImageTextModeXBin.prototype.parse = function(content) {
|
||||
var fontlength, headerData, offset;
|
||||
this.screen = [];
|
||||
headerData = content.substr(0, 11);
|
||||
if (headerData.length !== 11 || !headerData.match('^XBIN\x1a')) {
|
||||
throw new Error('File is not an XBin');
|
||||
}
|
||||
this.header.width = this.unpackShort(headerData.substr(5, 2));
|
||||
this.header.height = this.unpackShort(headerData.substr(7, 2));
|
||||
this.header.fontsize = this.getByteAt(headerData.substr(9, 1));
|
||||
this.header.flags = this.getByteAt(headerData.substr(10, 1));
|
||||
offset = 11;
|
||||
if (this.header.flags & PALETTE) {
|
||||
this.parsePaletteData(content.substr(offset, 48));
|
||||
offset += 48;
|
||||
}
|
||||
if (this.header.flags & FONT) {
|
||||
fontlength = this.header.fontsize;
|
||||
if (this.header.flags & FIVETWELVE_CHARS) {
|
||||
fontlength *= 512;
|
||||
} else {
|
||||
fontlength *= 256;
|
||||
}
|
||||
this.parseFontData(content.substr(offset, fontlength), this.header.fontsize);
|
||||
offset += fontlength;
|
||||
}
|
||||
if (this.header.flags & COMPRESSED) {
|
||||
return this._parse_compressed(content.substr(offset));
|
||||
} else {
|
||||
return this._parse_uncompressed(content.substr(offset));
|
||||
}
|
||||
};
|
||||
|
||||
ImageTextModeXBin.prototype._parse_compressed = function(data) {
|
||||
var attr, ch, counter, info, type, x, y, _results;
|
||||
x = 0;
|
||||
y = 0;
|
||||
this.screen[y] = [];
|
||||
data = data.split('');
|
||||
_results = [];
|
||||
while (info = data.shift()) {
|
||||
info = this.getByteAt(info, 0);
|
||||
if (info === 26) {
|
||||
break;
|
||||
}
|
||||
type = info & COMPRESSION_TYPE;
|
||||
counter = (info & COMPRESSION_COUNTER) + 1;
|
||||
ch = null;
|
||||
attr = null;
|
||||
_results.push((function() {
|
||||
var _results1;
|
||||
_results1 = [];
|
||||
while (counter-- > 0) {
|
||||
switch (type) {
|
||||
case NO_COMPRESSION:
|
||||
ch = data.shift();
|
||||
attr = data.shift();
|
||||
break;
|
||||
case CHARACTER_COMPRESSION:
|
||||
if (ch == null) {
|
||||
ch = data.shift();
|
||||
}
|
||||
attr = data.shift();
|
||||
break;
|
||||
case ATTRIBUTE_COMPRESSION:
|
||||
if (attr == null) {
|
||||
attr = data.shift();
|
||||
}
|
||||
ch = data.shift();
|
||||
break;
|
||||
default:
|
||||
if (ch == null) {
|
||||
ch = data.shift();
|
||||
}
|
||||
if (attr == null) {
|
||||
attr = data.shift();
|
||||
}
|
||||
}
|
||||
this.screen[y][x] = {
|
||||
ch: ch,
|
||||
attr: this.getByteAt(attr, 0)
|
||||
};
|
||||
x++;
|
||||
if (x === this.header.width) {
|
||||
x = 0;
|
||||
y++;
|
||||
if (y === this.header.height) {
|
||||
break;
|
||||
}
|
||||
if (this.screen[y] == null) {
|
||||
_results1.push(this.screen[y] = []);
|
||||
} else {
|
||||
_results1.push(void 0);
|
||||
}
|
||||
} else {
|
||||
_results1.push(void 0);
|
||||
}
|
||||
}
|
||||
return _results1;
|
||||
}).call(this));
|
||||
}
|
||||
return _results;
|
||||
};
|
||||
|
||||
ImageTextModeXBin.prototype._parse_uncompressed = function(data) {
|
||||
var attr, ch, i, x, y, _i, _ref, _results;
|
||||
x = 0;
|
||||
y = 0;
|
||||
this.screen[y] = [];
|
||||
_results = [];
|
||||
for (i = _i = 0, _ref = data.length - 2; _i <= _ref; i = _i += 2) {
|
||||
ch = data.substr(i, 1);
|
||||
if (ch === "\x1a") {
|
||||
break;
|
||||
}
|
||||
attr = this.getByteAt(data, i + 1);
|
||||
this.screen[y][x] = {
|
||||
'ch': ch,
|
||||
'attr': attr
|
||||
};
|
||||
x++;
|
||||
if (x === this.header.width) {
|
||||
x = 0;
|
||||
y++;
|
||||
if (y === this.header.height) {
|
||||
break;
|
||||
}
|
||||
if (this.screen[y] == null) {
|
||||
_results.push(this.screen[y] = []);
|
||||
} else {
|
||||
_results.push(void 0);
|
||||
}
|
||||
} else {
|
||||
_results.push(void 0);
|
||||
}
|
||||
}
|
||||
return _results;
|
||||
};
|
||||
|
||||
ImageTextModeXBin.prototype.getWidth = function() {
|
||||
return this.header.width;
|
||||
};
|
||||
|
||||
ImageTextModeXBin.prototype.getHeight = function() {
|
||||
return this.header.height;
|
||||
};
|
||||
|
||||
return ImageTextModeXBin;
|
||||
|
||||
})(this.ImageTextMode);
|
||||
|
||||
}).call(this);
|
||||
Loading…
Add table
Add a link
Reference in a new issue