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
const FORCE_HTTPS=!1;"https:"===location.protocol&&"serviceWorker"in navigator&&"www.marcrobledo.com"===window.location.hostname&&navigator.serviceWorker.register("/RomPatcher.js/_cache_service_worker.js",{scope:"/RomPatcher.js/"});const LOCAL_STORAGE_SETTINGS_ID="rom-patcher-js-settings",settings={language:"string"==typeof navigator.userLanguage?navigator.userLanguage.substr(0,2):"en",outputSuffix:!0,fixChecksum:!1,theme:"default"};if("undefined"!=typeof localStorage&&localStorage.getItem("rom-patcher-js-settings"))try{const e=JSON.parse(localStorage.getItem("rom-patcher-js-settings"));"string"==typeof e.language&&(settings.language=e.language),"boolean"==typeof e.outputSuffix&&(settings.outputSuffix=e.outputSuffix),"boolean"==typeof e.fixChecksum&&(settings.fixChecksum=e.fixChecksum),"string"==typeof e.theme&&-1!==["light"].indexOf(e.theme)&&(settings.theme=e.theme)}catch(e){console.error("Error while loading settings: "+e.message)}"light"===settings.theme&&document.body.classList.add("theme-light");const buildSettingsForWebapp=function(){return{language:settings.language,outputSuffix:settings.outputSuffix,fixChecksum:settings.fixChecksum,allowDropFiles:!0,ondropfiles:function(e){"creator"===currentMode&&switchMode("patch")}}};let currentMode="patch";function initCustomUI(){window.matchMedia&&window.matchMedia("(prefers-color-scheme: light)").matches&&"default"===settings.theme&&document.body.classList.add("theme-light"),window.matchMedia&&window.matchMedia("(prefers-color-scheme: light)").addEventListener("change",e=>{"default"===settings.theme&&(e.matches?document.body.classList.add("theme-light"):document.body.classList.remove("theme-light"))})}function initModeToggle(){document.querySelectorAll(".mode-segment").forEach(e=>{e.addEventListener("click",function(){switchMode(this.getAttribute("data-mode"))})})}function switchMode(e){const t=document.querySelectorAll(".mode-segment"),i=document.getElementById("rom-patcher-container"),n=document.getElementById("patch-builder-container"),o=document.getElementById("rom-patcher-button-apply"),s=document.getElementById("patch-builder-button-create");if(t.forEach(t=>{t.getAttribute("data-mode")===e?t.classList.add("selected"):t.classList.remove("selected")}),"patch"===e)currentMode="patch",i.classList.add("active"),i.style.display="block",n.classList.remove("active"),n.style.display="none",o.style.display="block",s.style.display="none";else{currentMode="creator",i.classList.remove("active"),i.style.display="none",n.classList.add("active"),n.style.display="block",o.style.display="none",s.style.display="block";try{"undefined"==typeof PatchBuilderWeb||PatchBuilderWeb.isInitialized()||PatchBuilderWeb.initialize()}catch(e){console.error("Error initializing PatchBuilderWeb:",e),n.innerHTML=e.message,n.style.color="red"}enableCreatorModeInputs()}}function enableCreatorModeInputs(){const e=document.getElementById("patch-builder-select-patch-type"),t=document.getElementById("patch-builder-input-file-original"),i=document.getElementById("patch-builder-input-file-modified");e&&(e.disabled=!1),t&&(t.disabled=!1),i&&(i.disabled=!1)}function initProgressiveDisclosure(){const e=document.getElementById("rom-patcher-input-file-rom"),t=document.getElementById("rom-file-input-wrapper"),i=document.getElementById("rom-loaded-container"),n=document.getElementById("rom-filename-display"),o=document.getElementById("rom-change-file-button"),s=document.getElementById("patch-file-section");e&&i&&o&&(e.addEventListener("change",function(){if(this.files&&this.files.length>0){const e=this.files[0].name;t.style.display="none",i.style.display="block",n.textContent=e,s&&(s.style.display="block")}else t.style.display="block",i.style.display="none",s&&(s.style.display="none")}),o.addEventListener("click",function(){e.click()}));const l=document.getElementById("rom-patcher-input-file-patch"),c=document.getElementById("patch-file-input-wrapper"),a=document.getElementById("patch-loaded-container"),d=document.getElementById("patch-filename-display"),r=document.getElementById("patch-change-file-button");l&&a&&r&&(l.addEventListener("change",function(){if(this.files&&this.files.length>0){const e=this.files[0].name;c.style.display="none",a.style.display="block",d.textContent=e}else c.style.display="block",a.style.display="none"}),r.addEventListener("click",function(){l.click()}));const m=document.getElementById("patch-builder-input-file-original"),u=document.getElementById("original-rom-section"),g=document.getElementById("original-rom-loaded-container"),p=document.getElementById("original-rom-filename-display"),h=document.getElementById("original-rom-change-file-button");if(m&&g&&h&&u){const e=u.querySelector(".file-input-wrapper");m.addEventListener("change",function(){if(this.files&&this.files.length>0){const t=this.files[0].name;g.style.display="block",p.textContent=t,e&&(e.style.display="none")}else g.style.display="none",e&&(e.style.display="block");checkCreatorModeFiles()}),h.addEventListener("click",function(){m.click()})}const f=document.getElementById("patch-builder-input-file-modified"),y=document.getElementById("modified-rom-section"),b=document.getElementById("modified-rom-loaded-container"),E=document.getElementById("modified-rom-filename-display"),I=document.getElementById("modified-rom-change-file-button");if(f&&b&&I&&y){const e=y.querySelector(".file-input-wrapper");f.addEventListener("change",function(){if(this.files&&this.files.length>0){const t=this.files[0].name;b.style.display="block",E.textContent=t,e&&(e.style.display="none")}else b.style.display="none",e&&(e.style.display="block");checkCreatorModeFiles()}),I.addEventListener("click",function(){f.click()})}}function checkCreatorModeFiles(){const e=document.getElementById("patch-builder-input-file-original"),t=document.getElementById("patch-builder-input-file-modified"),i=document.getElementById("patch-builder-button-create");if(e&&t&&i){const n=e.files&&e.files.length>0,o=t.files&&t.files.length>0;n&&o&&setTimeout(()=>{i.disabled&&(i.disabled=!1)},500)}}function initFileInputCustomization(){}function escapeHtml(e){const t={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.replace(/[&<>"']/g,e=>t[e])}function saveSettings(){if("undefined"!=typeof localStorage)try{localStorage.setItem("rom-patcher-js-settings",JSON.stringify(settings))}catch(e){console.error("Error saving settings: "+e.message)}}window.addEventListener("load",function(){try{RomPatcherWeb.initialize(buildSettingsForWebapp()),initCustomUI(),initModeToggle(),initFileInputCustomization(),initProgressiveDisclosure()}catch(t){var e=t.message;(/incompatible browser/i.test(e)||/variable RomPatcherWeb/i.test(e))&&(e="Your browser is outdated and it is not compatible with this app."),document.getElementById("rom-patcher-container").innerHTML=e,document.getElementById("rom-patcher-container").style.color="red"}});