// // narc.js //-------------------- // Reads narc archives and provides access to files by directory structure. // by RHY3756547 // window.narc = function(input) { this.load = load; this.getFile = getFile; var arc = this; var handlers = []; window.onmousemove = function(evt) { mouseX = evt.pageX; mouseY = evt.pageY; } this.scopeEval = function(code) {return eval(code)} //for debug purposes function load(buffer) { arc.buffer = buffer; //we will use this data in the future. var view = new DataView(buffer); arc.stamp = readChar(view, 0x0)+readChar(view, 0x1)+readChar(view, 0x2)+readChar(view, 0x3); if (arc.stamp != "NARC") throw "File provided is not a NARC archive! Expected NARC, found "+arc.stamp+"."; arc.byteOrder = view.getUint16(0x4, true); //todo: check byte order and flip to little endian when necessary arc.version = view.getUint16(0x6, true); arc.size = view.getUint32(0x8, true); arc.headSize = view.getUint16(0xC, true); arc.numBlocks = view.getUint16(0xE, true); var off = arc.headSize; arc.sections = {}; for (var i=0; i