Skip to content

Manic EMU is an all-in-one retro game emulator for iOS. It packs powerful features while keeping a clean, sleek UI and delivering buttery-smooth gameplay.

Swift
11.8 KB
Raw Blame
!function(e){"use strict";var t,r="File format is not recognized.",n="Error while reading zip file.",i="Error while reading file data.",o=524288,a="text/plain";try{t=0===new Blob([new DataView(new ArrayBuffer(0))]).size}catch(u){}function s(){this.crc=-1}function c(){}function f(e,t){var r,n;return r=new ArrayBuffer(e),n=new Uint8Array(r),t&&n.set(t,0),{buffer:r,array:n,view:new DataView(r)}}function u(){}function l(e){var t,r=this;r.size=0,r.init=function(n,i){var o=new Blob([e],{type:a});(t=new h(o)).init(function(){r.size=t.size,n()},i)},r.readUint8Array=function(e,r,n,i){t.readUint8Array(e,r,n,i)}}function w(t){var r,n=this;n.size=0,n.init=function(e){for(var i=t.length;"="==t.charAt(i-1);)i--;r=t.indexOf(",")+1,n.size=Math.floor(.75*(i-r)),e()},n.readUint8Array=function(n,i,o){var a,s=f(i),c=4*Math.floor(n/3),u=4*Math.ceil((n+i)/3),l=e.atob(t.substring(c+r,u+r)),w=n-3*Math.floor(c/4);for(a=w;a<w+i;a++)s.array[a-w]=l.charCodeAt(a);o(s.array)}}function h(e){var t=this;t.size=0,t.init=function(r){t.size=e.size,r()},t.readUint8Array=function(t,r,n,i){var o=new FileReader;o.onload=function(e){n(new Uint8Array(e.target.result))},o.onerror=i;try{o.readAsArrayBuffer(function(e,t,r){if(t<0||r<0||t+r>e.size)throw new RangeError("offset:"+t+", length:"+r+", size:"+e.size);return e.slice?e.slice(t,t+r):e.webkitSlice?e.webkitSlice(t,t+r):e.mozSlice?e.mozSlice(t,t+r):e.msSlice?e.msSlice(t,t+r):void 0}(e,t,r))}catch(t){i(t)}}}function p(){}function v(e){var r;this.init=function(e){r=new Blob([],{type:a}),e()},this.writeUint8Array=function(e,n){r=new Blob([r,t?e:e.buffer],{type:a}),n()},this.getData=function(t,n){var i=new FileReader;i.onload=function(e){t(e.target.result)},i.onerror=n,i.readAsText(r,e)}}function d(t){var r="",n="";this.init=function(e){r+="data:"+(t||"")+";base64,",e()},this.writeUint8Array=function(t,i){var o,a=n.length,s=n;for(n="",o=0;o<3*Math.floor((a+t.length)/3)-a;o++)s+=String.fromCharCode(t[o]);for(;o<t.length;o++)n+=String.fromCharCode(t[o]);2<s.length?r+=e.btoa(s):n=s,i()},this.getData=function(t){t(r+e.btoa(n))}}function g(e){var r;this.init=function(t){r=new Blob([],{type:e}),t()},this.writeUint8Array=function(n,i){r=new Blob([r,t?n:n.buffer],{type:e}),i()},this.getData=function(e){e(r)}}function y(e,t,r,n,i,a,s,c,f,u){var l,w,h,p=0,v=t.sn;function d(){e.removeEventListener("message",g,!1),c(w,h)}function g(t){var r=t.data,i=r.data,o=r.error;if(o)return o.toString=function(){return"Error: "+this.message},void f(o);if(r.sn===v)switch("number"==typeof r.codecTime&&(e.codecTime+=r.codecTime),"number"==typeof r.crcTime&&(e.crcTime+=r.crcTime),r.type){case"append":i?(w+=i.length,n.writeUint8Array(i,function(){y()},u)):y();break;case"flush":h=r.crc,i?(w+=i.length,n.writeUint8Array(i,function(){d()},u)):d();break;case"progress":s&&s(l+r.loaded,a);break;case"importScripts":case"newTask":case"echo":break;default:console.warn("zip.js:launchWorkerProcess: unknown message: ",r)}}function y(){(l=p*o)<=a?r.readUint8Array(i+l,Math.min(o,a-l),function(r){s&&s(l,a);var n=0===l?t:{sn:v};n.type="append",n.data=r;try{e.postMessage(n,[r.buffer])}catch(r){e.postMessage(n)}p++},f):e.postMessage({sn:v,type:"flush"})}w=0,e.addEventListener("message",g,!1),y()}function m(e,t,r,n,i,a,c,f,u,l){var w,h=0,p=0,v="input"===a,d="output"===a,g=new s;!function a(){var s;if((w=h*o)<i)t.readUint8Array(n+w,Math.min(o,i-w),function(t){var n;try{n=e.append(t,function(e){c&&c(w+e,i)})}catch(t){return void u(t)}n?(p+=n.length,r.writeUint8Array(n,function(){h++,setTimeout(a,1)},l),d&&g.append(n)):(h++,setTimeout(a,1)),v&&g.append(t),c&&c(w,i)},u);else{try{s=e.flush()}catch(s){return void u(s)}s?(d&&g.append(s),p+=s.length,r.writeUint8Array(s,function(){f(p,g.get())},l)):f(p,g.get())}}()}function U(t,r,n,i,o,a,s,f,u,l,w){e.zip.useWebWorkers&&s?y(t,{sn:r,codecClass:"NOOP",crcType:"input"},n,i,o,a,u,f,l,w):m(new c,n,i,o,a,"input",u,f,l,w)}function z(e){var t,r,n="",i=["Ç","ü","é","â","ä","à","å","ç","ê","ë","è","ï","î","ì","Ä","Å","É","æ","Æ","ô","ö","ò","û","ù","ÿ","Ö","Ü","ø","£","Ø","×","ƒ","á","í","ó","ú","ñ","Ñ","ª","º","¿","®","¬","½","¼","¡","«","»","_","_","_","¦","¦","Á","Â","À","©","¦","¦","+","+","¢","¥","+","+","-","-","+","-","+","ã","Ã","+","+","-","-","¦","-","+","¤","ð","Ð","Ê","Ë","È","i","Í","Î","Ï","+","+","_","_","¦","Ì","_","Ó","ß","Ô","Ò","õ","Õ","µ","þ","Þ","Ú","Û","Ù","ý","Ý","¯","´","­","±","_","¾","¶","§","÷","¸","°","¨","·","¹","³","²","_"," "];for(t=0;t<e.length;t++)n+=127<(r=255&e.charCodeAt(t))?i[r-128]:String.fromCharCode(r);return n}function b(e){return decodeURIComponent(escape(e))}function k(e){var t,r="";for(t=0;t<e.length;t++)r+=String.fromCharCode(e[t]);return r}function A(e,t,r,n,i){e.version=t.view.getUint16(r,!0),e.bitFlag=t.view.getUint16(r+2,!0),e.compressionMethod=t.view.getUint16(r+4,!0),e.lastModDateRaw=t.view.getUint32(r+6,!0),e.lastModDate=function(e){var t=(4294901760&e)>>16,r=65535&e;try{return new Date(1980+((65024&t)>>9),((480&t)>>5)-1,31&t,(63488&r)>>11,(2016&r)>>5,2*(31&r),0)}catch(e){}}(e.lastModDateRaw),1&~e.bitFlag?((n||!!(8&~e.bitFlag))&&(e.crc32=t.view.getUint32(r+10,!0),e.compressedSize=t.view.getUint32(r+14,!0),e.uncompressedSize=t.view.getUint32(r+18,!0)),4294967295!==e.compressedSize&&4294967295!==e.uncompressedSize?(e.filenameLength=t.view.getUint16(r+22,!0),e.extraFieldLength=t.view.getUint16(r+24,!0)):i("File is using Zip64 (4gb+ file size).")):i("File contains encrypted entry.")}function S(e){return unescape(encodeURIComponent(e))}function _(e){var t,r=[];for(t=0;t<e.length;t++)r.push(e.charCodeAt(t));return r}function D(t,r,n,o){var a={},s=[],c=0,u=0;function l(e){n(e||"Error while writing zip file.")}function w(e){n(e||i)}var h={add:function(r,i,h,p,v){var d,g,z,b=this._worker;function k(e,r){var n=f(16);c+=e||0,n.view.setUint32(0,1347094280),void 0!==r&&(d.view.setUint32(10,r,!0),n.view.setUint32(4,r,!0)),i&&(n.view.setUint32(8,e,!0),d.view.setUint32(14,e,!0),n.view.setUint32(12,i.size,!0),d.view.setUint32(18,i.size,!0)),t.writeUint8Array(n.array,function(){c+=16,h()},l)}function A(){var h,A;v=v||{},r=r.trim(),v.directory&&"/"!=r.charAt(r.length-1)&&(r+="/"),a.hasOwnProperty(r)?n("File already exists."):(g=_(S(r)),s.push(r),h=function(){var r,n,a,s,c,f,h,d,g;i?o||0===v.level?U(b,u++,i,t,0,i.size,!0,k,p,w,l):(r=b,n=u++,a=i,s=t,c=v.level,f=k,h=p,d=w,g=l,e.zip.useWebWorkers?y(r,{sn:n,options:{level:c},codecClass:"Deflater",crcType:"input"},a,s,0,a.size,h,f,d,g):m(new e.zip.Deflater,a,s,0,a.size,"input",h,f,d,g)):k()},z=v.lastModDate||new Date,d=f(26),a[r]={headerArray:d.array,directory:v.directory,filename:g,offset:c,comment:_(S(v.comment||""))},d.view.setUint32(0,335546376),v.version&&d.view.setUint8(0,v.version),o||0===v.level||v.directory||d.view.setUint16(4,2048),d.view.setUint16(6,(z.getHours()<<6|z.getMinutes())<<5|z.getSeconds()/2,!0),d.view.setUint16(8,(z.getFullYear()-1980<<4|z.getMonth()+1)<<5|z.getDate(),!0),d.view.setUint16(22,g.length,!0),(A=f(30+g.length)).view.setUint32(0,1347093252),A.array.set(d.array,4),A.array.set(g,30),c+=A.array.length,t.writeUint8Array(A.array,h,l))}i?i.init(A,w):A()},close:function(e){this._worker&&(this._worker.terminate(),this._worker=null);var r,n,i,o=0,u=0;for(n=0;n<s.length;n++)o+=46+(i=a[s[n]]).filename.length+i.comment.length;for(r=f(o+22),n=0;n<s.length;n++)i=a[s[n]],r.view.setUint32(u,1347092738),r.view.setUint16(u+4,5120),r.array.set(i.headerArray,u+6),r.view.setUint16(u+32,i.comment.length,!0),i.directory&&r.view.setUint8(u+38,16),r.view.setUint32(u+42,i.offset,!0),r.array.set(i.filename,u+46),r.array.set(i.comment,u+46+i.filename.length),u+=46+i.filename.length+i.comment.length;r.view.setUint32(u,1347093766),r.view.setUint16(u+8,s.length,!0),r.view.setUint16(u+10,s.length,!0),r.view.setUint32(u+12,o,!0),r.view.setUint32(u+16,c,!0),t.writeUint8Array(r.array,function(){t.getData(e)},l)},_worker:null};e.zip.useWebWorkers?M("deflater",function(e){h._worker=e,r(h)},function(e){n(e)}):r(h)}s.prototype.append=function(e){for(var t=0|this.crc,r=this.table,n=0,i=0|e.length;n<i;n++)t=t>>>8^r[255&(t^e[n])];this.crc=t},s.prototype.get=function(){return~this.crc},s.prototype.table=function(){var e,t,r,n=[];for(e=0;e<256;e++){for(r=e,t=0;t<8;t++)1&r?r=r>>>1^3988292384:r>>>=1;n[e]=r}return n}(),c.prototype.append=function(e,t){return e},c.prototype.flush=function(){},(l.prototype=new u).constructor=l,(w.prototype=new u).constructor=w,(h.prototype=new u).constructor=h,p.prototype.getData=function(e){e(this.data)},(v.prototype=new p).constructor=v,(d.prototype=new p).constructor=d,(g.prototype=new p).constructor=g;var L={deflater:["z-worker.js","deflate.js"],inflater:["z-worker.js","inflate.js"]};function M(t,r,n){if(null===e.zip.workerScripts||null===e.zip.workerScriptsPath){var i,o,a;if(e.zip.workerScripts){if(i=e.zip.workerScripts[t],!Array.isArray(i))return void n(new Error("zip.workerScripts."+t+" is not an array!"));o=i,a=document.createElement("a"),i=o.map(function(e){return a.href=e,a.href})}else(i=L[t].slice(0))[0]=(e.zip.workerScriptsPath||"")+i[0];var s=new Worker(i[0]);s.codecTime=s.crcTime=0,s.postMessage({type:"importScripts",scripts:i.slice(1)}),s.addEventListener("message",function e(t){var i=t.data;if(i.error)return s.terminate(),void n(i.error);"importScripts"===i.type&&(s.removeEventListener("message",e),s.removeEventListener("error",c),r(s))}),s.addEventListener("error",c)}else n(new Error("Either zip.workerScripts or zip.workerScriptsPath may be set, not both."));function c(e){s.terminate(),n(e)}}function W(e){console.error(e)}e.zip={Reader:u,Writer:p,BlobReader:h,Data64URIReader:w,TextReader:l,BlobWriter:g,Data64URIWriter:d,TextWriter:v,createReader:function(t,o,a){a=a||W,t.init(function(){!function(t,o,a){var s=0;function c(){}c.prototype.getData=function(n,o,c,u){var l=this;function w(e,t){var r,i;u&&(r=t,(i=f(4)).view.setUint32(0,r),l.crc32!=i.view.getUint32(0))?a("CRC failed."):n.getData(function(e){o(e)})}function h(e){a(e||i)}function p(e){a(e||"Error while writing file data.")}t.readUint8Array(l.offset,30,function(i){var o,v=f(i.length,i);1347093252==v.view.getUint32(0)?(A(l,v,4,!1,a),o=l.offset+30+l.filenameLength+l.extraFieldLength,n.init(function(){var r,i,a,f,v,d,g,z,b,k,A;0===l.compressionMethod?U(l._worker,s++,t,n,o,l.compressedSize,u,w,c,h,p):(r=l._worker,i=s++,a=t,f=n,v=o,d=l.compressedSize,g=w,z=c,b=h,k=p,A=u?"output":"none",e.zip.useWebWorkers?y(r,{sn:i,codecClass:"Inflater",crcType:A},a,f,v,d,z,g,b,k):m(new e.zip.Inflater,a,f,v,d,A,z,g,b,k))},p)):a(r)},h)};var u={getEntries:function(e){var i=this._worker;!function(e){function i(r,i){t.readUint8Array(t.size-r,r,function(t){for(var r=t.length-22;0<=r;r--)if(80===t[r]&&75===t[r+1]&&5===t[r+2]&&6===t[r+3])return void e(new DataView(t.buffer,r,22));i()},function(){a(n)})}t.size<22?a(r):i(22,function(){i(Math.min(65558,t.size),function(){a(r)})})}(function(o){var s,u;s=o.getUint32(16,!0),u=o.getUint16(8,!0),s<0||s>=t.size?a(r):t.readUint8Array(s,t.size-s,function(t){var n,o,s,l,w=0,h=[],p=f(t.length,t);for(n=0;n<u;n++){if((o=new c)._worker=i,1347092738!=p.view.getUint32(w))return void a(r);A(o,p,w+6,!0,a),o.commentLength=p.view.getUint16(w+32,!0),o.directory=!(16&~p.view.getUint8(w+38)),o.offset=p.view.getUint32(w+42,!0),s=k(p.array.subarray(w+46,w+46+o.filenameLength)),o.filename=2048&~o.bitFlag?z(s):b(s),o.directory||"/"!=o.filename.charAt(o.filename.length-1)||(o.directory=!0),l=k(p.array.subarray(w+46+o.filenameLength+o.extraFieldLength,w+46+o.filenameLength+o.extraFieldLength+o.commentLength)),o.comment=2048&~o.bitFlag?z(l):b(l),h.push(o),w+=46+o.filenameLength+o.extraFieldLength+o.commentLength}e(h)},function(){a(n)})})},close:function(e){this._worker&&(this._worker.terminate(),this._worker=null),e&&e()},_worker:null};e.zip.useWebWorkers?M("inflater",function(e){u._worker=e,o(u)},function(e){a(e)}):o(u)}(t,o,a)},a)},createWriter:function(e,t,r,n){r=r||W,n=!!n,e.init(function(){D(e,t,r,n)},r)},useWebWorkers:!0,workerScriptsPath:null,workerScripts:null}}(this);