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);
|
||||
Loading…
Add table
Add a link
Reference in a new issue