From 6f6f4f04d7480a03507fcb1836faec39b45f00b5 Mon Sep 17 00:00:00 2001 From: sehugg Date: Sun, 5 Nov 2023 21:29:57 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20sehugg/8?= =?UTF-8?q?bitworkshop@fe6a8a651414d67cf65e01de860feaffb231e712=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 16 + ...{apple2-4S4D3K4N.js => apple2-YBSXME7B.js} | 4 +- ...4S4D3K4N.js.map => apple2-YBSXME7B.js.map} | 0 gen/{arm32-ZZE4VEXM.js => arm32-TREQBG5P.js} | 4 +- ...-ZZE4VEXM.js.map => arm32-TREQBG5P.js.map} | 0 ...cade-VLTUF6PT.js => astrocade-HTRRXIK3.js} | 4 +- ...UF6PT.js.map => astrocade-HTRRXIK3.js.map} | 0 ...7800-LNLQFL4H.js => atari7800-TFVORQV6.js} | 4 +- ...QFL4H.js.map => atari7800-TFVORQV6.js.map} | 0 ...{atari8-AI5453LS.js => atari8-YJPSBKKM.js} | 4 +- ...AI5453LS.js.map => atari8-YJPSBKKM.js.map} | 0 gen/{basic-LB3JIOIE.js => basic-35NRKUG4.js} | 4 +- ...-LB3JIOIE.js.map => basic-35NRKUG4.js.map} | 0 gen/{c64-TM7UF3FD.js => c64-BMMLIOW3.js} | 4 +- ...64-TM7UF3FD.js.map => c64-BMMLIOW3.js.map} | 0 gen/{chunk-VFRMSBSH.js => chunk-36G23HSA.js} | 4 +- ...-VFRMSBSH.js.map => chunk-36G23HSA.js.map} | 0 gen/chunk-47V4PEOO.js | 6 - gen/chunk-5XVCUSSZ.js | 2 - gen/{chunk-GBZ35D7O.js => chunk-ASAEALE3.js} | 4 +- ...-GBZ35D7O.js.map => chunk-ASAEALE3.js.map} | 0 gen/{chunk-7TOHRG6S.js => chunk-BMGQJMLR.js} | 4 +- ...-7TOHRG6S.js.map => chunk-BMGQJMLR.js.map} | 0 gen/chunk-FULWX6T7.js | 48 + ...-UC5KI5RU.js.map => chunk-FULWX6T7.js.map} | 4 +- gen/{chunk-4UNLDFGJ.js => chunk-GKVIY6GD.js} | 8 +- ...-4UNLDFGJ.js.map => chunk-GKVIY6GD.js.map} | 4 +- gen/{chunk-RDEVPY4D.js => chunk-LBWPHUUP.js} | 4 +- ...-RDEVPY4D.js.map => chunk-LBWPHUUP.js.map} | 4 +- gen/chunk-RQFURXHW.js | 2 + ...-5XVCUSSZ.js.map => chunk-RQFURXHW.js.map} | 0 gen/{chunk-SXEVG2WS.js => chunk-SDBJC2RS.js} | 4 +- ...-SXEVG2WS.js.map => chunk-SDBJC2RS.js.map} | 0 gen/chunk-UC5KI5RU.js | 48 - gen/{chunk-5SHCNQ2O.js => chunk-XMPGMPQ4.js} | 4 +- ...-5SHCNQ2O.js.map => chunk-XMPGMPQ4.js.map} | 0 gen/chunk-YL2YTMD7.js | 6 + ...-47V4PEOO.js.map => chunk-YL2YTMD7.js.map} | 2 +- ...oard-IV56MLOR.js => clipboard-45L7WF2O.js} | 4 +- ...6MLOR.js.map => clipboard-45L7WF2O.js.map} | 0 ...{coleco-TXD5WC6L.js => coleco-UYR442DB.js} | 4 +- ...TXD5WC6L.js.map => coleco-UYR442DB.js.map} | 0 gen/common/baseplatform.js | 8 +- gen/common/baseplatform.js.map | 2 +- gen/common/script/env.js | 304 --- gen/common/script/env.js.map | 1 - gen/common/script/lib/bitmap.js | 456 ---- gen/common/script/lib/bitmap.js.map | 1 - gen/common/script/lib/color.js | 164 -- gen/common/script/lib/color.js.map | 1 - gen/common/script/lib/io.js | 183 -- gen/common/script/lib/io.js.map | 1 - gen/common/script/lib/output.js | 94 - gen/common/script/lib/output.js.map | 1 - gen/common/script/lib/scriptui.js | 175 -- gen/common/script/lib/scriptui.js.map | 1 - gen/common/script/ui/notebook.js | 475 ---- gen/common/script/ui/notebook.js.map | 1 - gen/{cpc-INZFMQI3.js => cpc-HUFG6J63.js} | 4 +- ...pc-INZFMQI3.js.map => cpc-HUFG6J63.js.map} | 0 gen/{devel-243ULGYJ.js => devel-UKB7TGVA.js} | 4 +- ...-243ULGYJ.js.map => devel-UKB7TGVA.js.map} | 0 gen/embedui.js | 2 +- ...axian-OS2HIV5P.js => galaxian-FCF3DRM7.js} | 4 +- ...2HIV5P.js.map => galaxian-FCF3DRM7.js.map} | 0 gen/ide/project.js | 15 +- gen/ide/project.js.map | 2 +- gen/ide/ui.js | 2 + gen/ide/ui.js.map | 2 +- ....min-DI47XKVW.js => jszip.min-R7NPJJ5M.js} | 4 +- ...7XKVW.js.map => jszip.min-R7NPJJ5M.js.map} | 0 gen/{kim1-FGEQPCHB.js => kim1-EPKUB26X.js} | 4 +- ...1-FGEQPCHB.js.map => kim1-EPKUB26X.js.map} | 0 gen/machine/williams.js.map | 2 +- ...kdown-SXIVCS44.js => markdown-27KGUVXA.js} | 4 +- ...IVCS44.js.map => markdown-27KGUVXA.js.map} | 0 gen/{msx-5JNDU2BA.js => msx-5N5BLDFV.js} | 4 +- ...sx-5JNDU2BA.js.map => msx-5N5BLDFV.js.map} | 0 ...080bw-HDYAIDFJ.js => mw8080bw-W2SMVMRK.js} | 4 +- ...YAIDFJ.js.map => mw8080bw-W2SMVMRK.js.map} | 0 gen/nes-6NOIMK6Q.js | 26 + ...es-RNFXR7ZS.js.map => nes-6NOIMK6Q.js.map} | 2 +- gen/nes-RNFXR7ZS.js | 26 - gen/{pce-SARX7NOR.js => pce-Z3J65ZWJ.js} | 4 +- ...ce-SARX7NOR.js.map => pce-Z3J65ZWJ.js.map} | 0 gen/platform/_index.js | 1 - gen/platform/_index.js.map | 2 +- gen/platform/script.js | 39 - gen/platform/script.js.map | 1 - gen/script-I5SUTSTV.js | 83 - gen/script-I5SUTSTV.js.map | 7 - gen/server/server.js | 6 +- gen/server/server.js.map | 4 +- gen/{sms-RC5FS7TY.js => sms-5STOQI37.js} | 4 +- ...ms-RC5FS7TY.js.map => sms-5STOQI37.js.map} | 0 ...i-WWVZCWBD.js => sound_konami-CQ4LTCUO.js} | 4 +- ...BD.js.map => sound_konami-CQ4LTCUO.js.map} | 0 ...DUTEP6RN.js => sound_williams-6QV2GA6Z.js} | 4 +- ....js.map => sound_williams-6QV2GA6Z.js.map} | 0 gen/ui.js | 2 +- gen/vcs-EWPDANHH.js | 19 - gen/vcs-YW2QIB2C.js | 19 + ...cs-EWPDANHH.js.map => vcs-YW2QIB2C.js.map} | 2 +- ...{vector-QUHYR6GI.js => vector-IGLTS555.js} | 4 +- ...QUHYR6GI.js.map => vector-IGLTS555.js.map} | 0 ...ectrex-WTVN32XJ.js => vectrex-JJII7IWB.js} | 4 +- ...TVN32XJ.js.map => vectrex-JJII7IWB.js.map} | 0 ...erilog-6NRAKSSK.js => verilog-JSCFDLAX.js} | 4 +- ...NRAKSSK.js.map => verilog-JSCFDLAX.js.map} | 0 gen/{vic20-GJDBBYAO.js => vic20-EAD2ZP6L.js} | 4 +- ...-GJDBBYAO.js.map => vic20-EAD2ZP6L.js.map} | 0 ...icdual-YW3PAD7K.js => vicdual-OH44ND2U.js} | 4 +- ...W3PAD7K.js.map => vicdual-OH44ND2U.js.map} | 0 gen/williams-IVXZLH67.js.map | 7 - ...liams-IVXZLH67.js => williams-QZ76FE77.js} | 4 +- gen/williams-QZ76FE77.js.map | 7 + gen/worker/bundle.js | 4 +- gen/worker/bundle.js.map | 4 +- gen/worker/server/buildenv.js | 2 +- gen/worker/server/buildenv.js.map | 2 +- gen/worker/tools/remote.js | 6 +- gen/worker/tools/remote.js.map | 2 +- gen/worker/tools/script.js | 72 - gen/worker/tools/script.js.map | 1 - gen/worker/workermain.js | 2 - gen/worker/workermain.js.map | 2 +- gen/{x86-6PHHUZYZ.js => x86-7OPY5QGY.js} | 4 +- ...86-6PHHUZYZ.js.map => x86-7OPY5QGY.js.map} | 0 ...chine-ULNL57FQ.js => zmachine-AHTXFQQ6.js} | 4 +- ...NL57FQ.js.map => zmachine-AHTXFQQ6.js.map} | 0 gen/{zx-ESOBP2P7.js => zx-3WTSFWBG.js} | 4 +- ...{zx-ESOBP2P7.js.map => zx-3WTSFWBG.js.map} | 0 nightwatch.json | 2 +- package-lock.json | 2234 +++++++++++++++-- package.json | 10 +- presets/c64/sidmacros.h | 6 +- presets/pce/skeleton.cc65 | 14 + presets/williams/skeleton.cmoc | 23 + src/common/baseplatform.ts | 5 +- src/common/script/env.ts | 294 --- src/common/script/lib/bitmap.ts | 474 ---- src/common/script/lib/color.ts | 163 -- src/common/script/lib/io.ts | 178 -- src/common/script/lib/output.ts | 85 - src/common/script/lib/scriptui.ts | 193 -- src/common/script/ui/notebook.ts | 479 ---- src/ide/project.ts | 14 +- src/ide/ui.ts | 2 + src/machine/williams.ts | 1 - src/platform/_index.ts | 1 - src/platform/script.ts | 46 - src/worker/server/buildenv.ts | 2 +- src/worker/tools/remote.ts | 7 +- src/worker/tools/script.ts | 46 - src/worker/unfinished.js | 46 - src/worker/workermain.ts | 3 - 156 files changed, 2356 insertions(+), 4509 deletions(-) rename gen/{apple2-4S4D3K4N.js => apple2-YBSXME7B.js} (98%) rename gen/{apple2-4S4D3K4N.js.map => apple2-YBSXME7B.js.map} (100%) rename gen/{arm32-ZZE4VEXM.js => arm32-TREQBG5P.js} (99%) rename gen/{arm32-ZZE4VEXM.js.map => arm32-TREQBG5P.js.map} (100%) rename gen/{astrocade-VLTUF6PT.js => astrocade-HTRRXIK3.js} (98%) rename gen/{astrocade-VLTUF6PT.js.map => astrocade-HTRRXIK3.js.map} (100%) rename gen/{atari7800-LNLQFL4H.js => atari7800-TFVORQV6.js} (97%) rename gen/{atari7800-LNLQFL4H.js.map => atari7800-TFVORQV6.js.map} (100%) rename gen/{atari8-AI5453LS.js => atari8-YJPSBKKM.js} (98%) rename gen/{atari8-AI5453LS.js.map => atari8-YJPSBKKM.js.map} (100%) rename gen/{basic-LB3JIOIE.js => basic-35NRKUG4.js} (98%) rename gen/{basic-LB3JIOIE.js.map => basic-35NRKUG4.js.map} (100%) rename gen/{c64-TM7UF3FD.js => c64-BMMLIOW3.js} (96%) rename gen/{c64-TM7UF3FD.js.map => c64-BMMLIOW3.js.map} (100%) rename gen/{chunk-VFRMSBSH.js => chunk-36G23HSA.js} (96%) rename gen/{chunk-VFRMSBSH.js.map => chunk-36G23HSA.js.map} (100%) delete mode 100644 gen/chunk-47V4PEOO.js delete mode 100644 gen/chunk-5XVCUSSZ.js rename gen/{chunk-GBZ35D7O.js => chunk-ASAEALE3.js} (98%) rename gen/{chunk-GBZ35D7O.js.map => chunk-ASAEALE3.js.map} (100%) rename gen/{chunk-7TOHRG6S.js => chunk-BMGQJMLR.js} (97%) rename gen/{chunk-7TOHRG6S.js.map => chunk-BMGQJMLR.js.map} (100%) create mode 100644 gen/chunk-FULWX6T7.js rename gen/{chunk-UC5KI5RU.js.map => chunk-FULWX6T7.js.map} (64%) rename gen/{chunk-4UNLDFGJ.js => chunk-GKVIY6GD.js} (98%) rename gen/{chunk-4UNLDFGJ.js.map => chunk-GKVIY6GD.js.map} (92%) rename gen/{chunk-RDEVPY4D.js => chunk-LBWPHUUP.js} (72%) rename gen/{chunk-RDEVPY4D.js.map => chunk-LBWPHUUP.js.map} (92%) create mode 100644 gen/chunk-RQFURXHW.js rename gen/{chunk-5XVCUSSZ.js.map => chunk-RQFURXHW.js.map} (100%) rename gen/{chunk-SXEVG2WS.js => chunk-SDBJC2RS.js} (99%) rename gen/{chunk-SXEVG2WS.js.map => chunk-SDBJC2RS.js.map} (100%) delete mode 100644 gen/chunk-UC5KI5RU.js rename gen/{chunk-5SHCNQ2O.js => chunk-XMPGMPQ4.js} (97%) rename gen/{chunk-5SHCNQ2O.js.map => chunk-XMPGMPQ4.js.map} (100%) create mode 100644 gen/chunk-YL2YTMD7.js rename gen/{chunk-47V4PEOO.js.map => chunk-YL2YTMD7.js.map} (78%) rename gen/{clipboard-IV56MLOR.js => clipboard-45L7WF2O.js} (98%) rename gen/{clipboard-IV56MLOR.js.map => clipboard-45L7WF2O.js.map} (100%) rename gen/{coleco-TXD5WC6L.js => coleco-UYR442DB.js} (94%) rename gen/{coleco-TXD5WC6L.js.map => coleco-UYR442DB.js.map} (100%) delete mode 100644 gen/common/script/env.js delete mode 100644 gen/common/script/env.js.map delete mode 100644 gen/common/script/lib/bitmap.js delete mode 100644 gen/common/script/lib/bitmap.js.map delete mode 100644 gen/common/script/lib/color.js delete mode 100644 gen/common/script/lib/color.js.map delete mode 100644 gen/common/script/lib/io.js delete mode 100644 gen/common/script/lib/io.js.map delete mode 100644 gen/common/script/lib/output.js delete mode 100644 gen/common/script/lib/output.js.map delete mode 100644 gen/common/script/lib/scriptui.js delete mode 100644 gen/common/script/lib/scriptui.js.map delete mode 100644 gen/common/script/ui/notebook.js delete mode 100644 gen/common/script/ui/notebook.js.map rename gen/{cpc-INZFMQI3.js => cpc-HUFG6J63.js} (94%) rename gen/{cpc-INZFMQI3.js.map => cpc-HUFG6J63.js.map} (100%) rename gen/{devel-243ULGYJ.js => devel-UKB7TGVA.js} (92%) rename gen/{devel-243ULGYJ.js.map => devel-UKB7TGVA.js.map} (100%) rename gen/{galaxian-OS2HIV5P.js => galaxian-FCF3DRM7.js} (96%) rename gen/{galaxian-OS2HIV5P.js.map => galaxian-FCF3DRM7.js.map} (100%) rename gen/{jszip.min-DI47XKVW.js => jszip.min-R7NPJJ5M.js} (99%) rename gen/{jszip.min-DI47XKVW.js.map => jszip.min-R7NPJJ5M.js.map} (100%) rename gen/{kim1-FGEQPCHB.js => kim1-EPKUB26X.js} (95%) rename gen/{kim1-FGEQPCHB.js.map => kim1-EPKUB26X.js.map} (100%) rename gen/{markdown-SXIVCS44.js => markdown-27KGUVXA.js} (84%) rename gen/{markdown-SXIVCS44.js.map => markdown-27KGUVXA.js.map} (100%) rename gen/{msx-5JNDU2BA.js => msx-5N5BLDFV.js} (98%) rename gen/{msx-5JNDU2BA.js.map => msx-5N5BLDFV.js.map} (100%) rename gen/{mw8080bw-HDYAIDFJ.js => mw8080bw-W2SMVMRK.js} (90%) rename gen/{mw8080bw-HDYAIDFJ.js.map => mw8080bw-W2SMVMRK.js.map} (100%) create mode 100644 gen/nes-6NOIMK6Q.js rename gen/{nes-RNFXR7ZS.js.map => nes-6NOIMK6Q.js.map} (99%) delete mode 100644 gen/nes-RNFXR7ZS.js rename gen/{pce-SARX7NOR.js => pce-Z3J65ZWJ.js} (99%) rename gen/{pce-SARX7NOR.js.map => pce-Z3J65ZWJ.js.map} (100%) delete mode 100644 gen/platform/script.js delete mode 100644 gen/platform/script.js.map delete mode 100644 gen/script-I5SUTSTV.js delete mode 100644 gen/script-I5SUTSTV.js.map rename gen/{sms-RC5FS7TY.js => sms-5STOQI37.js} (94%) rename gen/{sms-RC5FS7TY.js.map => sms-5STOQI37.js.map} (100%) rename gen/{sound_konami-WWVZCWBD.js => sound_konami-CQ4LTCUO.js} (86%) rename gen/{sound_konami-WWVZCWBD.js.map => sound_konami-CQ4LTCUO.js.map} (100%) rename gen/{sound_williams-DUTEP6RN.js => sound_williams-6QV2GA6Z.js} (88%) rename gen/{sound_williams-DUTEP6RN.js.map => sound_williams-6QV2GA6Z.js.map} (100%) delete mode 100644 gen/vcs-EWPDANHH.js create mode 100644 gen/vcs-YW2QIB2C.js rename gen/{vcs-EWPDANHH.js.map => vcs-YW2QIB2C.js.map} (99%) rename gen/{vector-QUHYR6GI.js => vector-IGLTS555.js} (97%) rename gen/{vector-QUHYR6GI.js.map => vector-IGLTS555.js.map} (100%) rename gen/{vectrex-WTVN32XJ.js => vectrex-JJII7IWB.js} (98%) rename gen/{vectrex-WTVN32XJ.js.map => vectrex-JJII7IWB.js.map} (100%) rename gen/{verilog-6NRAKSSK.js => verilog-JSCFDLAX.js} (99%) rename gen/{verilog-6NRAKSSK.js.map => verilog-JSCFDLAX.js.map} (100%) rename gen/{vic20-GJDBBYAO.js => vic20-EAD2ZP6L.js} (94%) rename gen/{vic20-GJDBBYAO.js.map => vic20-EAD2ZP6L.js.map} (100%) rename gen/{vicdual-YW3PAD7K.js => vicdual-OH44ND2U.js} (92%) rename gen/{vicdual-YW3PAD7K.js.map => vicdual-OH44ND2U.js.map} (100%) delete mode 100644 gen/williams-IVXZLH67.js.map rename gen/{williams-IVXZLH67.js => williams-QZ76FE77.js} (98%) create mode 100644 gen/williams-QZ76FE77.js.map delete mode 100644 gen/worker/tools/script.js delete mode 100644 gen/worker/tools/script.js.map rename gen/{x86-6PHHUZYZ.js => x86-7OPY5QGY.js} (93%) rename gen/{x86-6PHHUZYZ.js.map => x86-7OPY5QGY.js.map} (100%) rename gen/{zmachine-ULNL57FQ.js => zmachine-AHTXFQQ6.js} (98%) rename gen/{zmachine-ULNL57FQ.js.map => zmachine-AHTXFQQ6.js.map} (100%) rename gen/{zx-ESOBP2P7.js => zx-3WTSFWBG.js} (93%) rename gen/{zx-ESOBP2P7.js.map => zx-3WTSFWBG.js.map} (100%) create mode 100644 presets/pce/skeleton.cc65 create mode 100644 presets/williams/skeleton.cmoc delete mode 100644 src/common/script/env.ts delete mode 100644 src/common/script/lib/bitmap.ts delete mode 100644 src/common/script/lib/color.ts delete mode 100644 src/common/script/lib/io.ts delete mode 100644 src/common/script/lib/output.ts delete mode 100644 src/common/script/lib/scriptui.ts delete mode 100644 src/common/script/ui/notebook.ts delete mode 100644 src/platform/script.ts delete mode 100644 src/worker/tools/script.ts diff --git a/README.md b/README.md index 54c80074..f1f9be36 100644 --- a/README.md +++ b/README.md @@ -112,3 +112,19 @@ The IDE uses custom forks for many of these, found at https://github.com/sehugg? * https://github.com/sehugg/8bit-tools * https://github.com/sehugg/awesome-8bitgamedev +## Tool Server (experimental) + +This is an experimental feature that relies on a Docker container to provide compiler tools like [llvm-mos](https://github.com/llvm-mos/llvm-mos-sdk). +Right now, you have to run locally and build your own docker container. + +```sh +docker build -t 8bitws-server-debian scripts/docker +docker run -p 3009:3009 8bitws-server-debian +echo '{"REMOTE_URL":"http://localhost:3009/build"}' > remote.json +``` + +Then add "&tool=llvm-mos" to your URL, like +[this](http://localhost:8000/?platform=c64&file=sprite_collision.c&tool=llvm-mos). +You can also rename your C files to have the suffix "-llvm.c". +Right now only the platforms c64, atari8, nes (NROM), and pce are supported. +Not very many of the current examples work with the new toolchain. diff --git a/gen/apple2-4S4D3K4N.js b/gen/apple2-YBSXME7B.js similarity index 98% rename from gen/apple2-4S4D3K4N.js rename to gen/apple2-YBSXME7B.js index c7691f93..be553ae5 100644 --- a/gen/apple2-4S4D3K4N.js +++ b/gen/apple2-YBSXME7B.js @@ -1,4 +1,4 @@ -import{a as r0}from"./chunk-7TOHRG6S.js";import{B as e0,I as t0,q as x0,t as a0,y as z}from"./chunk-4UNLDFGJ.js";import{J as G,O as b,g as W,k as V,l as X,r as $,t as A}from"./chunk-47V4PEOO.js";import"./chunk-5XVCUSSZ.js";var E=2051,l0=E,O=E,u0=O-l0,N=class extends x0{constructor(){super();this.cpuFrequency=1022727;this.sampleRate=this.cpuFrequency;this.cpuCyclesPerLine=65;this.cpuCyclesPerFrame=this.cpuCyclesPerLine*262;this.canvasWidth=280;this.numVisibleScanlines=192;this.numTotalScanlines=262;this.defaultROMSize=48896-2051;this.ram=new Uint8Array(77824);this.cpu=new a0;this.grdirty=new Array(49152>>7);this.grparams={dirty:this.grdirty,grswitch:P,mem:this.ram};this.kbdlatch=0;this.soundstate=0;this.auxRAMselected=!1;this.auxRAMbank=1;this.writeinhibit=!0;this.bank2rdoffset=0;this.bank2wroffset=0;this.slots=new Array(8);this.fakeDrive={readROM:x=>{var a=this.cpu.getPC();if(a>=50688&&a<50944)switch(x){case 0:return 0;case 1:return E&255;case 2:return E>>8&255;default:return 0}else switch(x){case 0:return this.rom&&(console.log(`Loading program into Apple ][ RAM at $${O.toString(16)}`),this.ram.set(this.rom.slice(u0),O)),76;case 1:return 32;case 3:return 0;case 5:return 3;case 7:return 60;default:return 0}},readConst:x=>0,read:x=>this.floatbus(),write:(x,a)=>{}};this.loadBIOS(new V().decode(X(atob(g0)))),this.connectCPUMemoryBus(this),this.bios[54170-(65536-this.bios.length)]=96}saveState(){return{c:this.cpu.saveState(),ram:this.ram.slice(),kbdlatch:this.kbdlatch,soundstate:this.soundstate,grswitch:this.grparams.grswitch,auxRAMselected:this.auxRAMselected,auxRAMbank:this.auxRAMbank,writeinhibit:this.writeinhibit,slots:this.slots.map(x=>x&&x.saveState&&x.saveState()),inputs:null}}loadState(x){this.cpu.loadState(x.c),this.ram.set(x.ram),this.kbdlatch=x.kbdlatch,this.soundstate=x.soundstate,this.grparams.grswitch=x.grswitch,this.auxRAMselected=x.auxRAMselected,this.auxRAMbank=x.auxRAMbank,this.writeinhibit=x.writeinhibit,this.setupLanguageCardConstants();for(var a=0;a>8!=198);x++);for(var x=0;x<2e6&&(this.cpu.advanceClock(),!(this.cpu.getPC()>>8<198));x++);}readConst(x){if(x<49152)return this.ram[x];if(x>=53248)return this.auxRAMselected?x>=57344?this.ram[x]:this.ram[x+this.bank2rdoffset]:this.bios[x-(65536-this.bios.length)];if(x>=49408&&x<51200){var a=x>>8&7;return(this.slots[a]&&this.slots[a].readConst(x&255))|0}else return 0}read(x){if(x&=65535,x<49152||x>=53248)return this.readConst(x);if(x<49408){var a=x>>4&15;switch(a){case 0:return this.kbdlatch;case 1:this.kbdlatch&=127;break;case 3:this.soundstate=this.soundstate^1;break;case 5:(x&15)<8&&((x&1)!=0?this.grparams.grswitch|=1<<(x>>1&7):this.grparams.grswitch&=~(1<<(x>>1&7)));break;case 6:switch(x&7){case 1:case 2:case 3:return this.floatbus()&127;case 4:case 5:return this.floatbus()|128;default:return this.floatbus()}case 7:if(x==49264)return this.floatbus()|128;case 8:return this.doLanguageCardIO(x);case 9:case 10:case 11:case 12:case 13:case 14:case 15:return(this.slots[a-8]&&this.slots[a-8].read(x&15))|0}}else if(x>=49408&&x<51200){var a=x>>8&7;return(this.slots[a]&&this.slots[a].readROM(x&255))|0}return this.floatbus()}write(x,a){if(x&=65535,a&=255,x<49152)this.ram[x]=a,this.grdirty[x>>7]=1;else if(x<49280)this.read(x);else if(x<49408){var r=x>>4&15;this.slots[r-8]&&this.slots[r-8].write(x&15,a)}else x>=53248&&!this.writeinhibit&&(x>=57344?this.ram[x]=a:this.ram[x+this.bank2wroffset]=a)}floatbus(){var x=this.frameCycles,a=Math.floor(x/65),r=Math.floor(x%65),d=this.ap2disp.getAddressForScanline(a);return this.readConst(d+r)}connectVideo(x){super.connectVideo(x),this.ap2disp=this.pixels&&new d0(this.pixels,this.grparams)}startScanline(){}drawScanline(){}advanceFrame(x){var a=super.advanceFrame(x);return this.ap2disp&&this.ap2disp.updateScreen(),a}advanceCPU(){return this.audio.feedSample(this.soundstate,1),super.advanceCPU()}setKeyInput(x,a,r){if(r&b.KeyDown){switch(a=0,x){case 16:case 17:case 18:break;case 8:if(a=8,r&b.Shift){this.cpu.reset();return}break;case 13:a=13;break;case 27:a=27;break;case 37:a=8;break;case 39:a=21;break;case 38:a=11;break;case 40:a=10;break;case 48:r&b.Shift&&(a=41);break;case 49:r&b.Shift&&(a=33);break;case 50:r&b.Shift&&(a=64);break;case 51:r&b.Shift&&(a=35);break;case 52:r&b.Shift&&(a=36);break;case 53:r&b.Shift&&(a=37);break;case 54:r&b.Shift&&(a=94);break;case 55:r&b.Shift&&(a=38);break;case 56:r&b.Shift&&(a=42);break;case 57:r&b.Shift&&(a=40);break;case 61:a=r&b.Shift?43:61;break;case 173:a=r&b.Shift?95:45;break;case 59:a=r&b.Shift?58:59;break;case 188:a=r&b.Shift?60:44;break;case 190:a=r&b.Shift?62:46;break;case 191:a=r&b.Shift?63:47;break;case 222:a=r&b.Shift?34:39;break;default:a=x,a>=97&&a<=122&&(a-=32),a>=65&&a<65+26&&r&b.Ctrl&&(a-=64)}a&&(this.kbdlatch=(a|128)&255)}}doLanguageCardIO(x){switch(x&15){case 0:case 4:this.auxRAMselected=!0,this.auxRAMbank=2,this.writeinhibit=!0;break;case 1:case 5:this.auxRAMselected=!1,this.auxRAMbank=2,this.writeinhibit=!1;break;case 2:case 6:case 10:case 14:this.auxRAMselected=!1,this.writeinhibit=!0;break;case 3:case 7:this.auxRAMselected=!0,this.auxRAMbank=2,this.writeinhibit=!1;break;case 8:case 12:this.auxRAMselected=!0,this.auxRAMbank=1,this.writeinhibit=!0;break;case 9:case 13:this.auxRAMselected=!1,this.auxRAMbank=1,this.writeinhibit=!1;break;case 11:case 15:this.auxRAMselected=!0,this.auxRAMbank=1,this.writeinhibit=!1;break}return this.setupLanguageCardConstants(),this.floatbus()}setupLanguageCardConstants(){this.auxRAMbank==2?this.bank2rdoffset=-4096:this.bank2rdoffset=12288,this.auxRAMbank==2?this.bank2wroffset=-4096:this.bank2wroffset=12288}getDebugCategories(){return["CPU","Stack","I/O","Disk"]}getDebugInfo(x,a){switch(x){case"I/O":return"AUX RAM Bank: "+a.auxRAMbank+` +import{a as r0}from"./chunk-BMGQJMLR.js";import{B as e0,I as t0,q as x0,t as a0,y as z}from"./chunk-GKVIY6GD.js";import{H as G,M as b,g as W,k as V,l as X,r as $,t as A}from"./chunk-YL2YTMD7.js";import"./chunk-RQFURXHW.js";var E=2051,l0=E,O=E,u0=O-l0,N=class extends x0{constructor(){super();this.cpuFrequency=1022727;this.sampleRate=this.cpuFrequency;this.cpuCyclesPerLine=65;this.cpuCyclesPerFrame=this.cpuCyclesPerLine*262;this.canvasWidth=280;this.numVisibleScanlines=192;this.numTotalScanlines=262;this.defaultROMSize=48896-2051;this.ram=new Uint8Array(77824);this.cpu=new a0;this.grdirty=new Array(49152>>7);this.grparams={dirty:this.grdirty,grswitch:P,mem:this.ram};this.kbdlatch=0;this.soundstate=0;this.auxRAMselected=!1;this.auxRAMbank=1;this.writeinhibit=!0;this.bank2rdoffset=0;this.bank2wroffset=0;this.slots=new Array(8);this.fakeDrive={readROM:x=>{var a=this.cpu.getPC();if(a>=50688&&a<50944)switch(x){case 0:return 0;case 1:return E&255;case 2:return E>>8&255;default:return 0}else switch(x){case 0:return this.rom&&(console.log(`Loading program into Apple ][ RAM at $${O.toString(16)}`),this.ram.set(this.rom.slice(u0),O)),76;case 1:return 32;case 3:return 0;case 5:return 3;case 7:return 60;default:return 0}},readConst:x=>0,read:x=>this.floatbus(),write:(x,a)=>{}};this.loadBIOS(new V().decode(X(atob(g0)))),this.connectCPUMemoryBus(this),this.bios[54170-(65536-this.bios.length)]=96}saveState(){return{c:this.cpu.saveState(),ram:this.ram.slice(),kbdlatch:this.kbdlatch,soundstate:this.soundstate,grswitch:this.grparams.grswitch,auxRAMselected:this.auxRAMselected,auxRAMbank:this.auxRAMbank,writeinhibit:this.writeinhibit,slots:this.slots.map(x=>x&&x.saveState&&x.saveState()),inputs:null}}loadState(x){this.cpu.loadState(x.c),this.ram.set(x.ram),this.kbdlatch=x.kbdlatch,this.soundstate=x.soundstate,this.grparams.grswitch=x.grswitch,this.auxRAMselected=x.auxRAMselected,this.auxRAMbank=x.auxRAMbank,this.writeinhibit=x.writeinhibit,this.setupLanguageCardConstants();for(var a=0;a>8!=198);x++);for(var x=0;x<2e6&&(this.cpu.advanceClock(),!(this.cpu.getPC()>>8<198));x++);}readConst(x){if(x<49152)return this.ram[x];if(x>=53248)return this.auxRAMselected?x>=57344?this.ram[x]:this.ram[x+this.bank2rdoffset]:this.bios[x-(65536-this.bios.length)];if(x>=49408&&x<51200){var a=x>>8&7;return(this.slots[a]&&this.slots[a].readConst(x&255))|0}else return 0}read(x){if(x&=65535,x<49152||x>=53248)return this.readConst(x);if(x<49408){var a=x>>4&15;switch(a){case 0:return this.kbdlatch;case 1:this.kbdlatch&=127;break;case 3:this.soundstate=this.soundstate^1;break;case 5:(x&15)<8&&((x&1)!=0?this.grparams.grswitch|=1<<(x>>1&7):this.grparams.grswitch&=~(1<<(x>>1&7)));break;case 6:switch(x&7){case 1:case 2:case 3:return this.floatbus()&127;case 4:case 5:return this.floatbus()|128;default:return this.floatbus()}case 7:if(x==49264)return this.floatbus()|128;case 8:return this.doLanguageCardIO(x);case 9:case 10:case 11:case 12:case 13:case 14:case 15:return(this.slots[a-8]&&this.slots[a-8].read(x&15))|0}}else if(x>=49408&&x<51200){var a=x>>8&7;return(this.slots[a]&&this.slots[a].readROM(x&255))|0}return this.floatbus()}write(x,a){if(x&=65535,a&=255,x<49152)this.ram[x]=a,this.grdirty[x>>7]=1;else if(x<49280)this.read(x);else if(x<49408){var r=x>>4&15;this.slots[r-8]&&this.slots[r-8].write(x&15,a)}else x>=53248&&!this.writeinhibit&&(x>=57344?this.ram[x]=a:this.ram[x+this.bank2wroffset]=a)}floatbus(){var x=this.frameCycles,a=Math.floor(x/65),r=Math.floor(x%65),d=this.ap2disp.getAddressForScanline(a);return this.readConst(d+r)}connectVideo(x){super.connectVideo(x),this.ap2disp=this.pixels&&new d0(this.pixels,this.grparams)}startScanline(){}drawScanline(){}advanceFrame(x){var a=super.advanceFrame(x);return this.ap2disp&&this.ap2disp.updateScreen(),a}advanceCPU(){return this.audio.feedSample(this.soundstate,1),super.advanceCPU()}setKeyInput(x,a,r){if(r&b.KeyDown){switch(a=0,x){case 16:case 17:case 18:break;case 8:if(a=8,r&b.Shift){this.cpu.reset();return}break;case 13:a=13;break;case 27:a=27;break;case 37:a=8;break;case 39:a=21;break;case 38:a=11;break;case 40:a=10;break;case 48:r&b.Shift&&(a=41);break;case 49:r&b.Shift&&(a=33);break;case 50:r&b.Shift&&(a=64);break;case 51:r&b.Shift&&(a=35);break;case 52:r&b.Shift&&(a=36);break;case 53:r&b.Shift&&(a=37);break;case 54:r&b.Shift&&(a=94);break;case 55:r&b.Shift&&(a=38);break;case 56:r&b.Shift&&(a=42);break;case 57:r&b.Shift&&(a=40);break;case 61:a=r&b.Shift?43:61;break;case 173:a=r&b.Shift?95:45;break;case 59:a=r&b.Shift?58:59;break;case 188:a=r&b.Shift?60:44;break;case 190:a=r&b.Shift?62:46;break;case 191:a=r&b.Shift?63:47;break;case 222:a=r&b.Shift?34:39;break;default:a=x,a>=97&&a<=122&&(a-=32),a>=65&&a<65+26&&r&b.Ctrl&&(a-=64)}a&&(this.kbdlatch=(a|128)&255)}}doLanguageCardIO(x){switch(x&15){case 0:case 4:this.auxRAMselected=!0,this.auxRAMbank=2,this.writeinhibit=!0;break;case 1:case 5:this.auxRAMselected=!1,this.auxRAMbank=2,this.writeinhibit=!1;break;case 2:case 6:case 10:case 14:this.auxRAMselected=!1,this.writeinhibit=!0;break;case 3:case 7:this.auxRAMselected=!0,this.auxRAMbank=2,this.writeinhibit=!1;break;case 8:case 12:this.auxRAMselected=!0,this.auxRAMbank=1,this.writeinhibit=!0;break;case 9:case 13:this.auxRAMselected=!1,this.auxRAMbank=1,this.writeinhibit=!1;break;case 11:case 15:this.auxRAMselected=!0,this.auxRAMbank=1,this.writeinhibit=!1;break}return this.setupLanguageCardConstants(),this.floatbus()}setupLanguageCardConstants(){this.auxRAMbank==2?this.bank2rdoffset=-4096:this.bank2rdoffset=12288,this.auxRAMbank==2?this.bank2wroffset=-4096:this.bank2wroffset=12288}getDebugCategories(){return["CPU","Stack","I/O","Disk"]}getDebugInfo(x,a){switch(x){case"I/O":return"AUX RAM Bank: "+a.auxRAMbank+` AUX RAM Select: `+a.auxRAMselected+` AUX RAM Write: `+!a.writeinhibit+` @@ -10,4 +10,4 @@ Mode: `+(this.read_mode?"READ":"WRITE")+` Motor: `+this.motor+` Data: `+(this.track_data?W(this.track_data[this.track_index]):"-")+` `}read_latch(){return this.track_index=(this.track_index+1)%H,this.track_data?this.track_data[this.track_index]&255:this.emu.floatbus()|128}write_latch(x){this.track_index=(this.track_index+1)%H,this.track_data!=null&&(this.track_data[this.track_index]=x)}readROM(x){return s0[x]}readConst(x){return s0[x]}read(x){return this.doIO(x,0)}write(x,a){this.doIO(x,a)}doIO(x,a){switch(x&15){case 1:case 3:case 5:case 7:var r,d,e;e=this.track,r=x>>1&3,r==(e-1&3)?e>0&&e--:r==(e+1&3)&&e>1],console.log("track",e/2)):this.track_data=null,this.track=e;break;case 8:this.motor=!1;break;case 9:this.motor=!0;break;case 10:break;case 11:break;case 15:this.read_mode=!1;case 12:if(this.read_mode)return this.read_latch();break;case 14:this.read_mode=!0;case 13:return a>=0&&!this.read_mode&&!this.write_protect&&this.write_latch(a),this.write_protect?128:0}return this.emu.floatbus()}},T=[150,151,154,155,157,158,159,166,167,171,172,173,174,175,178,179,180,181,182,183,185,186,187,188,189,190,191,203,205,206,207,211,214,215,217,218,219,220,221,222,223,229,230,231,233,234,235,236,237,238,239,242,243,244,245,246,247,249,250,251,252,253,254,255],S0=[0,7,14,6,13,5,12,4,11,3,10,2,9,1,8,15];function B0(i,x,a,r,d,e,n){var c,p,S,l,k=new Uint8Array(258);for(l=0,c=0;c<14;c++)e[n++]=255;for(e[n++]=213,e[n++]=170,e[n++]=150,e[n++]=i>>1|170,e[n++]=i|170,p=i,e[n++]=x>>1|170,e[n++]=x|170,p^=x,e[n++]=a>>1|170,e[n++]=a|170,p^=a,e[n++]=p>>1|170,e[n++]=p|170,e[n++]=222,e[n++]=170,e[n++]=235,c=0;c<6;c++)e[n++]=255;for(e[n++]=213,e[n++]=170,e[n++]=173,c=0;c<256;c++)k[c]=r[c+d]&255;for(k[256]=0,k[257]=0,S=0,c=0;c<86;c++)l=(k[c]&1)<<1,l|=(k[c]&2)>>1,l|=(k[c+86]&1)<<3,l|=(k[c+86]&2)<<1,l|=(k[c+172]&1)<<5,l|=(k[c+172]&2)<<3,e[n++]=T[l^S],S=l;for(c=0;c<256;c++)l=k[c]>>2,e[n++]=T[l^S],S=l;e[n++]=T[l],e[n++]=222,e[n++]=170,e[n++]=235}function p0(i,x,a){for(var r=new Uint8Array(H),d=0,e=0;e<16;e++)B0(i,x,e,a,S0[e]<<8,r,d),d+=C0;for(;dx.endsWith(".lnk")?"merlin32":z(x)}newMachine(){return new N}getPresets(){return n0}getDefaultExtension(){return".c"}readAddress(x){return this.machine.readConst(x)}getROMExtension(x){return x&&x.length==35*16*256?".dsk":".bin"}};G["apple2.mame"]=f0;G.apple2=o0; -//# sourceMappingURL=apple2-4S4D3K4N.js.map +//# sourceMappingURL=apple2-YBSXME7B.js.map diff --git a/gen/apple2-4S4D3K4N.js.map b/gen/apple2-YBSXME7B.js.map similarity index 100% rename from gen/apple2-4S4D3K4N.js.map rename to gen/apple2-YBSXME7B.js.map diff --git a/gen/arm32-ZZE4VEXM.js b/gen/arm32-TREQBG5P.js similarity index 99% rename from gen/arm32-ZZE4VEXM.js rename to gen/arm32-TREQBG5P.js index 3b0f9663..7574342b 100644 --- a/gen/arm32-ZZE4VEXM.js +++ b/gen/arm32-TREQBG5P.js @@ -1,7 +1,7 @@ -import{H as j,q}from"./chunk-4UNLDFGJ.js";import{$ as L,D as J,J as Y,S as y,V as S,W as z,Y as X,a as N,g as E}from"./chunk-47V4PEOO.js";import"./chunk-5XVCUSSZ.js";var g;(function(o){o[o.MODE_ARM=0]="MODE_ARM",o[o.MODE_THUMB=1]="MODE_THUMB",o[o.MODE_USER=16]="MODE_USER",o[o.MODE_FIQ=17]="MODE_FIQ",o[o.MODE_IRQ=18]="MODE_IRQ",o[o.MODE_SUPERVISOR=19]="MODE_SUPERVISOR",o[o.MODE_ABORT=23]="MODE_ABORT",o[o.MODE_UNDEFINED=27]="MODE_UNDEFINED",o[o.MODE_SYSTEM=31]="MODE_SYSTEM"})(g||(g={}));var u;(function(t){t[t.SP=13]="SP",t[t.LR=14]="LR",t[t.PC=15]="PC"})(u||(u={}));var b;(function(l){l[l.BANK_NONE=0]="BANK_NONE",l[l.BANK_FIQ=1]="BANK_FIQ",l[l.BANK_IRQ=2]="BANK_IRQ",l[l.BANK_SUPERVISOR=3]="BANK_SUPERVISOR",l[l.BANK_ABORT=4]="BANK_ABORT",l[l.BANK_UNDEFINED=5]="BANK_UNDEFINED",l[l.WORD_SIZE_ARM=4]="WORD_SIZE_ARM",l[l.WORD_SIZE_THUMB=2]="WORD_SIZE_THUMB",l[l.BASE_RESET=0]="BASE_RESET",l[l.BASE_UNDEF=4]="BASE_UNDEF",l[l.BASE_SWI=8]="BASE_SWI",l[l.BASE_PABT=12]="BASE_PABT",l[l.BASE_DABT=16]="BASE_DABT",l[l.BASE_IRQ=24]="BASE_IRQ",l[l.BASE_FIQ=28]="BASE_FIQ"})(b||(b={}));var $=4026531840,rr=223,or=32;function F(s){this.cpu=s,this.addressingMode23Immediate=[function(e,i,t){var r=s.gprs,a=function(){var c=r[e];return(!t||t())&&(r[e]-=i),c};return a.writesPC=e==15,a},null,null,null,function(e,i,t){var r=s.gprs,a=function(){var c=r[e];return(!t||t())&&(r[e]+=i),c};return a.writesPC=e==15,a},null,null,null,function(e,i,t){var r=s.gprs,a=function(){return r[e]-i};return a.writesPC=!1,a},function(e,i,t){var r=s.gprs,a=function(){var c=r[e]-i;return(!t||t())&&(r[e]=c),c};return a.writesPC=e==15,a},null,null,function(e,i,t){var r=s.gprs,a=function(){return r[e]+i};return a.writesPC=!1,a},function(e,i,t){var r=s.gprs,a=function(){var c=r[e]+i;return(!t||t())&&(r[e]=c),c};return a.writesPC=e==15,a},null,null],this.addressingMode23Register=[function(e,i,t){var r=s.gprs,a=function(){var c=r[e];return(!t||t())&&(r[e]-=r[i]),c};return a.writesPC=e==15,a},null,null,null,function(e,i,t){var r=s.gprs,a=function(){var c=r[e];return(!t||t())&&(r[e]+=r[i]),c};return a.writesPC=e==15,a},null,null,null,function(e,i,t){var r=s.gprs,a=function(){return r[e]-r[i]};return a.writesPC=!1,a},function(e,i,t){var r=s.gprs,a=function(){var c=r[e]-r[i];return(!t||t())&&(r[e]=c),c};return a.writesPC=e==15,a},null,null,function(e,i,t){var r=s.gprs,a=function(){var c=r[e]+r[i];return c};return a.writesPC=!1,a},function(e,i,t){var r=s.gprs,a=function(){var c=r[e]+r[i];return(!t||t())&&(r[e]=c),c};return a.writesPC=e==15,a},null,null],this.addressingMode2RegisterShifted=[function(e,i,t){var r=s.gprs,a=function(){var c=r[e];return(!t||t())&&(i(),r[e]-=s.shifterOperand),c};return a.writesPC=e==15,a},null,null,null,function(e,i,t){var r=s.gprs,a=function(){var c=r[e];return(!t||t())&&(i(),r[e]+=s.shifterOperand),c};return a.writesPC=e==15,a},null,null,null,function(e,i,t){var r=s.gprs,a=function(){return i(),r[e]-s.shifterOperand};return a.writesPC=!1,a},function(e,i,t){var r=s.gprs,a=function(){i();var c=r[e]-s.shifterOperand;return(!t||t())&&(r[e]=c),c};return a.writesPC=e==15,a},null,null,function(e,i,t){var r=s.gprs,a=function(){return i(),r[e]+s.shifterOperand};return a.writesPC=!1,a},function(e,i,t){var r=s.gprs,a=function(){i();var c=r[e]+s.shifterOperand;return(!t||t())&&(r[e]=c),c};return a.writesPC=e==15,a},null,null]}F.prototype.constructAddressingMode1ASR=function(s,e){var i=this.cpu,t=i.gprs;return function(){++i.cycles;var r=t[s];s==15&&(r+=4),r&=255;var a=t[e];e==15&&(a+=4),r==0?(i.shifterOperand=a,i.shifterCarryOut=i.cpsrC):r<32?(i.shifterOperand=a>>r,i.shifterCarryOut=a&1<>31?(i.shifterOperand=4294967295,i.shifterCarryOut=2147483648):(i.shifterOperand=0,i.shifterCarryOut=0)}};F.prototype.constructAddressingMode1Immediate=function(s){var e=this.cpu;return function(){e.shifterOperand=s,e.shifterCarryOut=e.cpsrC}};F.prototype.constructAddressingMode1ImmediateRotate=function(s,e){var i=this.cpu;return function(){i.shifterOperand=s>>>e|s<<32-e,i.shifterCarryOut=i.shifterOperand>>31}};F.prototype.constructAddressingMode1LSL=function(s,e){var i=this.cpu,t=i.gprs;return function(){++i.cycles;var r=t[s];s==15&&(r+=4),r&=255;var a=t[e];e==15&&(a+=4),r==0?(i.shifterOperand=a,i.shifterCarryOut=i.cpsrC):r<32?(i.shifterOperand=a<>>r,i.shifterCarryOut=a&1<>31):(i.shifterOperand=0,i.shifterCarryOut=0)}};F.prototype.constructAddressingMode1ROR=function(s,e){var i=this.cpu,t=i.gprs;return function(){++i.cycles;var r=t[s];s==15&&(r+=4),r&=255;var a=t[e];e==15&&(a+=4);var c=r&31;r==0?(i.shifterOperand=a,i.shifterCarryOut=i.cpsrC):c?(i.shifterOperand=t[e]>>>c|t[e]<<32-c,i.shifterCarryOut=a&1<>31)}};F.prototype.constructAddressingMode23Immediate=function(s,e,i){var t=(s&983040)>>16;return this.addressingMode23Immediate[(s&27262976)>>21](t,e,i)};F.prototype.constructAddressingMode23Register=function(s,e,i){var t=(s&983040)>>16;return this.addressingMode23Register[(s&27262976)>>21](t,e,i)};F.prototype.constructAddressingMode2RegisterShifted=function(s,e,i){var t=(s&983040)>>16;return this.addressingMode2RegisterShifted[(s&27262976)>>21](t,e,i)};F.prototype.constructAddressingMode4=function(s,e){var i=this.cpu,t=i.gprs;return function(){var r=t[e]+s;return r}};F.prototype.constructAddressingMode4Writeback=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(c){var p=a[i]+s;return c&&t&&r.mmu.store32(a[i]+s-4,a[i]),a[i]+=e,p}};F.prototype.constructADC=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){if(r.mmu.waitPrefetch32(a[15]),!(t&&!t())){i();var c=(r.shifterOperand>>>0)+(r.cpsrC?1:0);a[s]=(a[e]>>>0)+c}}};F.prototype.constructADCS=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){if(r.mmu.waitPrefetch32(a[15]),!(t&&!t())){i();var c=(r.shifterOperand>>>0)+(r.cpsrC?1:0),p=(a[e]>>>0)+c;s==15&&r.hasSPSR()?r.unpackCPSR(r.spsr):(r.cpsrN=p>>31,r.cpsrZ=!(p&4294967295),r.cpsrC=p>4294967295,r.cpsrV=a[e]>>31==c>>31&&a[e]>>31!=p>>31&&c>>31!=p>>31),a[s]=p}}};F.prototype.constructADD=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){r.mmu.waitPrefetch32(a[15]),!(t&&!t())&&(i(),a[s]=(a[e]>>>0)+(r.shifterOperand>>>0))}};F.prototype.constructADDS=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){if(r.mmu.waitPrefetch32(a[15]),!(t&&!t())){i();var c=(a[e]>>>0)+(r.shifterOperand>>>0);s==15&&r.hasSPSR()?r.unpackCPSR(r.spsr):(r.cpsrN=c>>31,r.cpsrZ=!(c&4294967295),r.cpsrC=c>4294967295,r.cpsrV=a[e]>>31==r.shifterOperand>>31&&a[e]>>31!=c>>31&&r.shifterOperand>>31!=c>>31),a[s]=c}}};F.prototype.constructAND=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){r.mmu.waitPrefetch32(a[15]),!(t&&!t())&&(i(),a[s]=a[e]&r.shifterOperand)}};F.prototype.constructANDS=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){r.mmu.waitPrefetch32(a[15]),!(t&&!t())&&(i(),a[s]=a[e]&r.shifterOperand,s==15&&r.hasSPSR()?r.unpackCPSR(r.spsr):(r.cpsrN=a[s]>>31,r.cpsrZ=!(a[s]&4294967295),r.cpsrC=r.shifterCarryOut))}};F.prototype.constructB=function(s,e){var i=this.cpu,t=i.gprs;return function(){if(e&&!e()){i.mmu.waitPrefetch32(t[15]);return}i.mmu.waitPrefetch32(t[15]),t[15]+=s}};F.prototype.constructBIC=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){r.mmu.waitPrefetch32(a[15]),!(t&&!t())&&(i(),a[s]=a[e]&~r.shifterOperand)}};F.prototype.constructBICS=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){r.mmu.waitPrefetch32(a[15]),!(t&&!t())&&(i(),a[s]=a[e]&~r.shifterOperand,s==15&&r.hasSPSR()?r.unpackCPSR(r.spsr):(r.cpsrN=a[s]>>31,r.cpsrZ=!(a[s]&4294967295),r.cpsrC=r.shifterCarryOut))}};F.prototype.constructBL=function(s,e){var i=this.cpu,t=i.gprs;return function(){if(e&&!e()){i.mmu.waitPrefetch32(t[15]);return}i.mmu.waitPrefetch32(t[15]),t[14]=t[15]-4,t[15]+=s}};F.prototype.constructBX=function(s,e){var i=this.cpu,t=i.gprs;return function(){if(e&&!e()){i.mmu.waitPrefetch32(t[15]);return}i.mmu.waitPrefetch32(t[15]),i.switchExecMode(t[s]&1),t[15]=t[s]&4294967294}};F.prototype.constructCMN=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){if(r.mmu.waitPrefetch32(a[15]),!(t&&!t())){i();var c=(a[e]>>>0)+(r.shifterOperand>>>0);r.cpsrN=c>>31,r.cpsrZ=!(c&4294967295),r.cpsrC=c>4294967295,r.cpsrV=a[e]>>31==r.shifterOperand>>31&&a[e]>>31!=c>>31&&r.shifterOperand>>31!=c>>31}}};F.prototype.constructCMP=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){if(r.mmu.waitPrefetch32(a[15]),!(t&&!t())){i();var c=a[e]-r.shifterOperand;r.cpsrN=c>>31,r.cpsrZ=!(c&4294967295),r.cpsrC=a[e]>>>0>=r.shifterOperand>>>0,r.cpsrV=a[e]>>31!=r.shifterOperand>>31&&a[e]>>31!=c>>31}}};F.prototype.constructEOR=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){r.mmu.waitPrefetch32(a[15]),!(t&&!t())&&(i(),a[s]=a[e]^r.shifterOperand)}};F.prototype.constructEORS=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){r.mmu.waitPrefetch32(a[15]),!(t&&!t())&&(i(),a[s]=a[e]^r.shifterOperand,s==15&&r.hasSPSR()?r.unpackCPSR(r.spsr):(r.cpsrN=a[s]>>31,r.cpsrZ=!(a[s]&4294967295),r.cpsrC=r.shifterCarryOut))}};F.prototype.constructLDM=function(s,e,i){var t=this.cpu,r=t.gprs,a=t.mmu;return function(){if(a.waitPrefetch32(r[15]),!(i&&!i())){var c=e(!1),p=0,n,o;for(n=s,o=0;n;n>>=1,++o)n&1&&(r[o]=a.load32(c&4294967292),c+=4,++p);a.waitMulti32(c,p),++t.cycles}}};F.prototype.constructLDMS=function(s,e,i){var t=this.cpu,r=t.gprs,a=t.mmu;return function(){if(a.waitPrefetch32(r[15]),!(i&&!i())){var c=e(!1),p=0,n=t.mode;t.switchMode(31);var o,v;for(o=s,v=0;o;o>>=1,++v)o&1&&(r[v]=a.load32(c&4294967292),c+=4,++p);t.switchMode(n),a.waitMulti32(c,p),++t.cycles}}};F.prototype.constructLDR=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){if(t.mmu.waitPrefetch32(r[15]),!(i&&!i())){var a=e();r[s]=t.mmu.load32(a),t.mmu.wait32(a),++t.cycles}}};F.prototype.constructLDRB=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){if(t.mmu.waitPrefetch32(r[15]),!(i&&!i())){var a=e();r[s]=t.mmu.loadU8(a),t.mmu.wait(a),++t.cycles}}};F.prototype.constructLDRH=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){if(t.mmu.waitPrefetch32(r[15]),!(i&&!i())){var a=e();r[s]=t.mmu.loadU16(a),t.mmu.wait(a),++t.cycles}}};F.prototype.constructLDRSB=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){if(t.mmu.waitPrefetch32(r[15]),!(i&&!i())){var a=e();r[s]=t.mmu.load8(a),t.mmu.wait(a),++t.cycles}}};F.prototype.constructLDRSH=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){if(t.mmu.waitPrefetch32(r[15]),!(i&&!i())){var a=e();r[s]=t.mmu.load16(a),t.mmu.wait(a),++t.cycles}}};F.prototype.constructMLA=function(s,e,i,t,r){var a=this.cpu,c=a.gprs;return function(){if(a.mmu.waitPrefetch32(c[15]),!(r&&!r()))if(++a.cycles,a.mmu.waitMul(i),c[t]&4294901760&&c[i]&4294901760){var p=(c[t]&4294901760)*c[i]&4294967295,n=(c[t]&65535)*c[i]&4294967295;c[s]=p+n+c[e]&4294967295}else c[s]=c[t]*c[i]+c[e]}};F.prototype.constructMLAS=function(s,e,i,t,r){var a=this.cpu,c=a.gprs;return function(){if(a.mmu.waitPrefetch32(c[15]),!(r&&!r())){if(++a.cycles,a.mmu.waitMul(i),c[t]&4294901760&&c[i]&4294901760){var p=(c[t]&4294901760)*c[i]&4294967295,n=(c[t]&65535)*c[i]&4294967295;c[s]=p+n+c[e]&4294967295}else c[s]=c[t]*c[i]+c[e];a.cpsrN=c[s]>>31,a.cpsrZ=!(c[s]&4294967295)}}};F.prototype.constructMOV=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){r.mmu.waitPrefetch32(a[15]),!(t&&!t())&&(i(),a[s]=r.shifterOperand)}};F.prototype.constructMOVS=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){r.mmu.waitPrefetch32(a[15]),!(t&&!t())&&(i(),a[s]=r.shifterOperand,s==15&&r.hasSPSR()?r.unpackCPSR(r.spsr):(r.cpsrN=a[s]>>31,r.cpsrZ=!(a[s]&4294967295),r.cpsrC=r.shifterCarryOut))}};F.prototype.constructMRS=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){t.mmu.waitPrefetch32(r[15]),!(i&&!i())&&(e?r[s]=t.spsr:r[s]=t.packCPSR())}};F.prototype.constructMSR=function(s,e,i,t,r){var a=this.cpu,c=a.gprs,p=i&65536,n=i&524288;return function(){if(a.mmu.waitPrefetch32(c[15]),!(r&&!r())){var o;i&33554432?o=t:o=c[s];var v=(p?255:0)|(n?4278190080:0);e?(v&=$|rr|or,a.spsr=a.spsr&~v|o&v):(v&$&&(a.cpsrN=o>>31,a.cpsrZ=o&1073741824,a.cpsrC=o&536870912,a.cpsrV=o&268435456),a.mode!=16&&v&rr&&(a.switchMode(o&15|16),a.cpsrI=o&128,a.cpsrF=o&64))}}};F.prototype.constructMUL=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){if(r.mmu.waitPrefetch32(a[15]),!(t&&!t()))if(r.mmu.waitMul(a[e]),a[i]&4294901760&&a[e]&4294901760){var c=(a[i]&4294901760)*a[e]|0,p=(a[i]&65535)*a[e]|0;a[s]=c+p}else a[s]=a[i]*a[e]}};F.prototype.constructMULS=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){if(r.mmu.waitPrefetch32(a[15]),!(t&&!t())){if(r.mmu.waitMul(a[e]),a[i]&4294901760&&a[e]&4294901760){var c=(a[i]&4294901760)*a[e]|0,p=(a[i]&65535)*a[e]|0;a[s]=c+p}else a[s]=a[i]*a[e];r.cpsrN=a[s]>>31,r.cpsrZ=!(a[s]&4294967295)}}};F.prototype.constructMVN=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){r.mmu.waitPrefetch32(a[15]),!(t&&!t())&&(i(),a[s]=~r.shifterOperand)}};F.prototype.constructMVNS=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){r.mmu.waitPrefetch32(a[15]),!(t&&!t())&&(i(),a[s]=~r.shifterOperand,s==15&&r.hasSPSR()?r.unpackCPSR(r.spsr):(r.cpsrN=a[s]>>31,r.cpsrZ=!(a[s]&4294967295),r.cpsrC=r.shifterCarryOut))}};F.prototype.constructORR=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){r.mmu.waitPrefetch32(a[15]),!(t&&!t())&&(i(),a[s]=a[e]|r.shifterOperand)}};F.prototype.constructORRS=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){r.mmu.waitPrefetch32(a[15]),!(t&&!t())&&(i(),a[s]=a[e]|r.shifterOperand,s==15&&r.hasSPSR()?r.unpackCPSR(r.spsr):(r.cpsrN=a[s]>>31,r.cpsrZ=!(a[s]&4294967295),r.cpsrC=r.shifterCarryOut))}};F.prototype.constructRSB=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){r.mmu.waitPrefetch32(a[15]),!(t&&!t())&&(i(),a[s]=r.shifterOperand-a[e])}};F.prototype.constructRSBS=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){if(r.mmu.waitPrefetch32(a[15]),!(t&&!t())){i();var c=r.shifterOperand-a[e];s==15&&r.hasSPSR()?r.unpackCPSR(r.spsr):(r.cpsrN=c>>31,r.cpsrZ=!(c&4294967295),r.cpsrC=r.shifterOperand>>>0>=a[e]>>>0,r.cpsrV=r.shifterOperand>>31!=a[e]>>31&&r.shifterOperand>>31!=c>>31),a[s]=c}}};F.prototype.constructRSC=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){if(r.mmu.waitPrefetch32(a[15]),!(t&&!t())){i();var c=(a[e]>>>0)+(r.cpsrC?0:1);a[s]=(r.shifterOperand>>>0)-c}}};F.prototype.constructRSCS=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){if(r.mmu.waitPrefetch32(a[15]),!(t&&!t())){i();var c=(a[e]>>>0)+(r.cpsrC?0:1),p=(r.shifterOperand>>>0)-c;s==15&&r.hasSPSR()?r.unpackCPSR(r.spsr):(r.cpsrN=p>>31,r.cpsrZ=!(p&4294967295),r.cpsrC=r.shifterOperand>>>0>=p>>>0,r.cpsrV=r.shifterOperand>>31!=c>>31&&r.shifterOperand>>31!=p>>31),a[s]=p}}};F.prototype.constructSBC=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){if(r.mmu.waitPrefetch32(a[15]),!(t&&!t())){i();var c=(r.shifterOperand>>>0)+(r.cpsrC?0:1);a[s]=(a[e]>>>0)-c}}};F.prototype.constructSBCS=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){if(r.mmu.waitPrefetch32(a[15]),!(t&&!t())){i();var c=(r.shifterOperand>>>0)+(r.cpsrC?0:1),p=(a[e]>>>0)-c;s==15&&r.hasSPSR()?r.unpackCPSR(r.spsr):(r.cpsrN=p>>31,r.cpsrZ=!(p&4294967295),r.cpsrC=a[e]>>>0>=p>>>0,r.cpsrV=a[e]>>31!=c>>31&&a[e]>>31!=p>>31),a[s]=p}}};F.prototype.constructSMLAL=function(s,e,i,t,r){var a=this.cpu,c=1/4294967296,p=a.gprs;return function(){if(a.mmu.waitPrefetch32(p[15]),!(r&&!r())){a.cycles+=2,a.mmu.waitMul(i);var n=(p[t]&4294901760)*p[i],o=(p[t]&65535)*p[i],v=(p[e]>>>0)+n+o;p[e]=v,p[s]+=Math.floor(v*c)}}};F.prototype.constructSMLALS=function(s,e,i,t,r){var a=this.cpu,c=1/4294967296,p=a.gprs;return function(){if(a.mmu.waitPrefetch32(p[15]),!(r&&!r())){a.cycles+=2,a.mmu.waitMul(i);var n=(p[t]&4294901760)*p[i],o=(p[t]&65535)*p[i],v=(p[e]>>>0)+n+o;p[e]=v,p[s]+=Math.floor(v*c),a.cpsrN=p[s]>>31,a.cpsrZ=!(p[s]&4294967295||p[e]&4294967295)}}};F.prototype.constructSMULL=function(s,e,i,t,r){var a=this.cpu,c=1/4294967296,p=a.gprs;return function(){if(a.mmu.waitPrefetch32(p[15]),!(r&&!r())){++a.cycles,a.mmu.waitMul(p[i]);var n=((p[t]&4294901760)>>0)*(p[i]>>0),o=((p[t]&65535)>>0)*(p[i]>>0);p[e]=(n&4294967295)+(o&4294967295)&4294967295,p[s]=Math.floor(n*c+o*c)}}};F.prototype.constructSMULLS=function(s,e,i,t,r){var a=this.cpu,c=1/4294967296,p=a.gprs;return function(){if(a.mmu.waitPrefetch32(p[15]),!(r&&!r())){++a.cycles,a.mmu.waitMul(p[i]);var n=((p[t]&4294901760)>>0)*(p[i]>>0),o=((p[t]&65535)>>0)*(p[i]>>0);p[e]=(n&4294967295)+(o&4294967295)&4294967295,p[s]=Math.floor(n*c+o*c),a.cpsrN=p[s]>>31,a.cpsrZ=!(p[s]&4294967295||p[e]&4294967295)}}};F.prototype.constructSTM=function(s,e,i){var t=this.cpu,r=t.gprs,a=t.mmu;return function(){if(i&&!i()){a.waitPrefetch32(r[15]);return}a.wait32(r[15]);var c=e(!0),p=0,n,o;for(n=s,o=0;n;n>>=1,++o)n&1&&(a.store32(c,r[o]),c+=4,++p);a.waitMulti32(c,p)}};F.prototype.constructSTMS=function(s,e,i){var t=this.cpu,r=t.gprs,a=t.mmu;return function(){if(i&&!i()){a.waitPrefetch32(r[15]);return}a.wait32(r[15]);var c=t.mode,p=e(!0),n=0,o,v;for(t.switchMode(31),o=s,v=0;o;o>>=1,++v)o&1&&(a.store32(p,r[v]),p+=4,++n);t.switchMode(c),a.waitMulti32(p,n)}};F.prototype.constructSTR=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){if(i&&!i()){t.mmu.waitPrefetch32(r[15]);return}var a=e();t.mmu.store32(a,r[s]),t.mmu.wait32(a),t.mmu.wait32(r[15])}};F.prototype.constructSTRB=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){if(i&&!i()){t.mmu.waitPrefetch32(r[15]);return}var a=e();t.mmu.store8(a,r[s]),t.mmu.wait(a),t.mmu.wait32(r[15])}};F.prototype.constructSTRH=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){if(i&&!i()){t.mmu.waitPrefetch32(r[15]);return}var a=e();t.mmu.store16(a,r[s]),t.mmu.wait(a),t.mmu.wait32(r[15])}};F.prototype.constructSUB=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){r.mmu.waitPrefetch32(a[15]),!(t&&!t())&&(i(),a[s]=a[e]-r.shifterOperand)}};F.prototype.constructSUBS=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){if(r.mmu.waitPrefetch32(a[15]),!(t&&!t())){i();var c=a[e]-r.shifterOperand;s==15&&r.hasSPSR()?r.unpackCPSR(r.spsr):(r.cpsrN=c>>31,r.cpsrZ=!(c&4294967295),r.cpsrC=a[e]>>>0>=r.shifterOperand>>>0,r.cpsrV=a[e]>>31!=r.shifterOperand>>31&&a[e]>>31!=c>>31),a[s]=c}}};F.prototype.constructSWI=function(s,e){var i=this.cpu,t=i.gprs;return function(){if(e&&!e()){i.mmu.waitPrefetch32(t[15]);return}i.irq.swi32(s),i.mmu.waitPrefetch32(t[15])}};F.prototype.constructSWP=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){if(r.mmu.waitPrefetch32(a[15]),!(t&&!t())){r.mmu.wait32(a[e]),r.mmu.wait32(a[e]);var c=r.mmu.load32(a[e]);r.mmu.store32(a[e],a[i]),a[s]=c,++r.cycles}}};F.prototype.constructSWPB=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){if(r.mmu.waitPrefetch32(a[15]),!(t&&!t())){r.mmu.wait(a[e]),r.mmu.wait(a[e]);var c=r.mmu.loadU8(a[e]);r.mmu.store8(a[e],a[i]),a[s]=c,++r.cycles}}};F.prototype.constructTEQ=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){if(r.mmu.waitPrefetch32(a[15]),!(t&&!t())){i();var c=a[e]^r.shifterOperand;r.cpsrN=c>>31,r.cpsrZ=!(c&4294967295),r.cpsrC=r.shifterCarryOut}}};F.prototype.constructTST=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){if(r.mmu.waitPrefetch32(a[15]),!(t&&!t())){i();var c=a[e]&r.shifterOperand;r.cpsrN=c>>31,r.cpsrZ=!(c&4294967295),r.cpsrC=r.shifterCarryOut}}};F.prototype.constructUMLAL=function(s,e,i,t,r){var a=this.cpu,c=1/4294967296,p=a.gprs;return function(){if(a.mmu.waitPrefetch32(p[15]),!(r&&!r())){a.cycles+=2,a.mmu.waitMul(i);var n=((p[t]&4294901760)>>>0)*(p[i]>>>0),o=(p[t]&65535)*(p[i]>>>0),v=(p[e]>>>0)+n+o;p[e]=v,p[s]+=v*c}}};F.prototype.constructUMLALS=function(s,e,i,t,r){var a=this.cpu,c=1/4294967296,p=a.gprs;return function(){if(a.mmu.waitPrefetch32(p[15]),!(r&&!r())){a.cycles+=2,a.mmu.waitMul(i);var n=((p[t]&4294901760)>>>0)*(p[i]>>>0),o=(p[t]&65535)*(p[i]>>>0),v=(p[e]>>>0)+n+o;p[e]=v,p[s]+=v*c,a.cpsrN=p[s]>>31,a.cpsrZ=!(p[s]&4294967295||p[e]&4294967295)}}};F.prototype.constructUMULL=function(s,e,i,t,r){var a=this.cpu,c=1/4294967296,p=a.gprs;return function(){if(a.mmu.waitPrefetch32(p[15]),!(r&&!r())){++a.cycles,a.mmu.waitMul(p[i]);var n=((p[t]&4294901760)>>>0)*(p[i]>>>0),o=((p[t]&65535)>>>0)*(p[i]>>>0);p[e]=(n&4294967295)+(o&4294967295)&4294967295,p[s]=n*c+o*c>>>0}}};F.prototype.constructUMULLS=function(s,e,i,t,r){var a=this.cpu,c=1/4294967296,p=a.gprs;return function(){if(a.mmu.waitPrefetch32(p[15]),!(r&&!r())){++a.cycles,a.mmu.waitMul(p[i]);var n=((p[t]&4294901760)>>>0)*(p[i]>>>0),o=((p[t]&65535)>>>0)*(p[i]>>>0);p[e]=(n&4294967295)+(o&4294967295)&4294967295,p[s]=n*c+o*c>>>0,a.cpsrN=p[s]>>31,a.cpsrZ=!(p[s]&4294967295||p[e]&4294967295)}}};function m(s){this.cpu=s}m.prototype.constructADC=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]);var r=(t[e]>>>0)+(i.cpsrC?1:0),a=t[s],c=(a>>>0)+r,p=a>>31,n=c>>31,o=r>>31;i.cpsrN=n,i.cpsrZ=!(c&4294967295),i.cpsrC=c>4294967295,i.cpsrV=p==o&&p!=n&&o!=n,t[s]=c}};m.prototype.constructADD1=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){t.mmu.waitPrefetch(r[15]);var a=(r[e]>>>0)+i;t.cpsrN=a>>31,t.cpsrZ=!(a&4294967295),t.cpsrC=a>4294967295,t.cpsrV=!(r[e]>>31)&&(r[e]>>31^a)>>31&&a>>31,r[s]=a}};m.prototype.constructADD2=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]);var r=(t[s]>>>0)+e;i.cpsrN=r>>31,i.cpsrZ=!(r&4294967295),i.cpsrC=r>4294967295,i.cpsrV=!(t[s]>>31)&&(t[s]^r)>>31&&(e^r)>>31,t[s]=r}};m.prototype.constructADD3=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){t.mmu.waitPrefetch(r[15]);var a=(r[e]>>>0)+(r[i]>>>0);t.cpsrN=a>>31,t.cpsrZ=!(a&4294967295),t.cpsrC=a>4294967295,t.cpsrV=!((r[e]^r[i])>>31)&&(r[e]^a)>>31&&(r[i]^a)>>31,r[s]=a}};m.prototype.constructADD4=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]),t[s]+=t[e]}};m.prototype.constructADD5=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]),t[s]=(t[15]&4294967292)+e}};m.prototype.constructADD6=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]),t[s]=t[13]+e}};m.prototype.constructADD7=function(s){var e=this.cpu,i=e.gprs;return function(){e.mmu.waitPrefetch(i[15]),i[13]+=s}};m.prototype.constructAND=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]),t[s]=t[s]&t[e],i.cpsrN=t[s]>>31,i.cpsrZ=!(t[s]&4294967295)}};m.prototype.constructASR1=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){t.mmu.waitPrefetch(r[15]),i==0?(t.cpsrC=r[e]>>31,t.cpsrC?r[s]=4294967295:r[s]=0):(t.cpsrC=r[e]&1<>i),t.cpsrN=r[s]>>31,t.cpsrZ=!(r[s]&4294967295)}};m.prototype.constructASR2=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]);var r=t[e]&255;r&&(r<32?(i.cpsrC=t[s]&1<>=r):(i.cpsrC=t[s]>>31,i.cpsrC?t[s]=4294967295:t[s]=0)),i.cpsrN=t[s]>>31,i.cpsrZ=!(t[s]&4294967295)}};m.prototype.constructB1=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]),e()&&(t[15]+=s)}};m.prototype.constructB2=function(s){var e=this.cpu,i=e.gprs;return function(){e.mmu.waitPrefetch(i[15]),i[15]+=s}};m.prototype.constructBIC=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]),t[s]=t[s]&~t[e],i.cpsrN=t[s]>>31,i.cpsrZ=!(t[s]&4294967295)}};m.prototype.constructBL1=function(s){var e=this.cpu,i=e.gprs;return function(){e.mmu.waitPrefetch(i[15]),i[14]=i[15]+s}};m.prototype.constructBL2=function(s){var e=this.cpu,i=e.gprs;return function(){e.mmu.waitPrefetch(i[15]);var t=i[15];i[15]=i[14]+(s<<1),i[14]=t-1}};m.prototype.constructBX=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]),i.switchExecMode(t[e]&1);var r=0;e==15&&(r=t[e]&2),t[15]=t[e]&4294967294-r}};m.prototype.constructCMN=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]);var r=(t[s]>>>0)+(t[e]>>>0);i.cpsrN=r>>31,i.cpsrZ=!(r&4294967295),i.cpsrC=r>4294967295,i.cpsrV=t[s]>>31==t[e]>>31&&t[s]>>31!=r>>31&&t[e]>>31!=r>>31}};m.prototype.constructCMP1=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]);var r=t[s]-e;i.cpsrN=r>>31,i.cpsrZ=!(r&4294967295),i.cpsrC=t[s]>>>0>=e,i.cpsrV=t[s]>>31&&(t[s]^r)>>31}};m.prototype.constructCMP2=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]);var r=t[s],a=t[e],c=r-a,p=c>>31,n=r>>31;i.cpsrN=p,i.cpsrZ=!(c&4294967295),i.cpsrC=r>>>0>=a>>>0,i.cpsrV=n!=a>>31&&n!=p}};m.prototype.constructCMP3=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]);var r=t[s]-t[e];i.cpsrN=r>>31,i.cpsrZ=!(r&4294967295),i.cpsrC=t[s]>>>0>=t[e]>>>0,i.cpsrV=(t[s]^t[e])>>31&&(t[s]^r)>>31}};m.prototype.constructEOR=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]),t[s]=t[s]^t[e],i.cpsrN=t[s]>>31,i.cpsrZ=!(t[s]&4294967295)}};m.prototype.constructLDMIA=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]);var r=t[s],a=0,c,p;for(c=1,p=0;p<8;c<<=1,++p)e&c&&(t[p]=i.mmu.load32(r),r+=4,++a);i.mmu.waitMulti32(r,a),1<>31,t.cpsrZ=!(r[s]&4294967295)}};m.prototype.constructLSL2=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]);var r=t[e]&255;r&&(r<32?(i.cpsrC=t[s]&1<<32-r,t[s]<<=r):(r>32?i.cpsrC=0:i.cpsrC=t[s]&1,t[s]=0)),i.cpsrN=t[s]>>31,i.cpsrZ=!(t[s]&4294967295)}};m.prototype.constructLSR1=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){t.mmu.waitPrefetch(r[15]),i==0?(t.cpsrC=r[e]>>31,r[s]=0):(t.cpsrC=r[e]&1<>>i),t.cpsrN=0,t.cpsrZ=!(r[s]&4294967295)}};m.prototype.constructLSR2=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]);var r=t[e]&255;r&&(r<32?(i.cpsrC=t[s]&1<>>=r):(r>32?i.cpsrC=0:i.cpsrC=t[s]>>31,t[s]=0)),i.cpsrN=t[s]>>31,i.cpsrZ=!(t[s]&4294967295)}};m.prototype.constructMOV1=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]),t[s]=e,i.cpsrN=e>>31,i.cpsrZ=!(e&4294967295)}};m.prototype.constructMOV2=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){t.mmu.waitPrefetch(r[15]);var a=r[e];t.cpsrN=a>>31,t.cpsrZ=!(a&4294967295),t.cpsrC=0,t.cpsrV=0,r[s]=a}};m.prototype.constructMOV3=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]),t[s]=t[e]}};m.prototype.constructMUL=function(s,e){var i=this.cpu,t=i.gprs;return function(){if(i.mmu.waitPrefetch(t[15]),i.mmu.waitMul(t[e]),t[e]&4294901760&&t[s]&4294901760){var r=(t[s]&4294901760)*t[e]&4294967295,a=(t[s]&65535)*t[e]&4294967295;t[s]=r+a&4294967295}else t[s]*=t[e];i.cpsrN=t[s]>>31,i.cpsrZ=!(t[s]&4294967295)}};m.prototype.constructMVN=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]),t[s]=~t[e],i.cpsrN=t[s]>>31,i.cpsrZ=!(t[s]&4294967295)}};m.prototype.constructNEG=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]);var r=-t[e];i.cpsrN=r>>31,i.cpsrZ=!(r&4294967295),i.cpsrC=0>=r>>>0,i.cpsrV=t[e]>>31&&r>>31,t[s]=r}};m.prototype.constructORR=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]),t[s]=t[s]|t[e],i.cpsrN=t[s]>>31,i.cpsrZ=!(t[s]&4294967295)}};m.prototype.constructPOP=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]),++i.cycles;var r=t[13],a=0,c,p;for(c=1,p=0;p<8;c<<=1,++p)s&c&&(i.mmu.waitSeq32(r),t[p]=i.mmu.load32(r),r+=4,++a);e&&(t[15]=i.mmu.load32(r)&4294967294,r+=4,++a),i.mmu.waitMulti32(r,a),t[13]=r}};m.prototype.constructPUSH=function(s,e){var i=this.cpu,t=i.gprs;return function(){var r=t[13]-4,a=0;i.mmu.waitPrefetch(t[15]),e&&(i.mmu.store32(r,t[14]),r-=4,++a);var c,p;for(c=128,p=7;c;c>>=1,--p)if(s&c){i.mmu.store32(r,t[p]),r-=4,++a;break}for(c>>=1,--p;c;c>>=1,--p)s&c&&(i.mmu.store32(r,t[p]),r-=4,++a);i.mmu.waitMulti32(r,a),t[13]=r+4}};m.prototype.constructROR=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]);var r=t[e]&255;if(r){var a=r&31;a>0?(i.cpsrC=t[s]&1<>>a|t[s]<<32-a):i.cpsrC=t[s]>>31}i.cpsrN=t[s]>>31,i.cpsrZ=!(t[s]&4294967295)}};m.prototype.constructSBC=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]);var r=(t[e]>>>0)+(i.cpsrC?0:1),a=(t[s]>>>0)-r;i.cpsrN=a>>31,i.cpsrZ=!(a&4294967295),i.cpsrC=t[s]>>>0>=a>>>0,i.cpsrV=(t[s]^r)>>31&&(t[s]^a)>>31,t[s]=a}};m.prototype.constructSTMIA=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.wait(t[15]);var r=t[s],a=0,c,p;for(c=1,p=0;p<8;c<<=1,++p)if(e&c){i.mmu.store32(r,t[p]),r+=4,++a;break}for(c<<=1,++p;p<8;c<<=1,++p)e&c&&(i.mmu.store32(r,t[p]),r+=4,++a);i.mmu.waitMulti32(r,a),t[s]=r}};m.prototype.constructSTR1=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){var a=r[e]+i;t.mmu.store32(a,r[s]),t.mmu.wait(r[15]),t.mmu.wait32(a)}};m.prototype.constructSTR2=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){t.mmu.store32(r[e]+r[i],r[s]),t.mmu.wait(r[15]),t.mmu.wait32(r[e]+r[i])}};m.prototype.constructSTR3=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.store32(t[13]+e,t[s]),i.mmu.wait(t[15]),i.mmu.wait32(t[13]+e)}};m.prototype.constructSTRB1=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){var a=r[e]+i;t.mmu.store8(a,r[s]),t.mmu.wait(r[15]),t.mmu.wait(a)}};m.prototype.constructSTRB2=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){t.mmu.store8(r[e]+r[i],r[s]),t.mmu.wait(r[15]),t.mmu.wait(r[e]+r[i])}};m.prototype.constructSTRH1=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){var a=r[e]+i;t.mmu.store16(a,r[s]),t.mmu.wait(r[15]),t.mmu.wait(a)}};m.prototype.constructSTRH2=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){t.mmu.store16(r[e]+r[i],r[s]),t.mmu.wait(r[15]),t.mmu.wait(r[e]+r[i])}};m.prototype.constructSUB1=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){t.mmu.waitPrefetch(r[15]);var a=r[e]-i;t.cpsrN=a>>31,t.cpsrZ=!(a&4294967295),t.cpsrC=r[e]>>>0>=i,t.cpsrV=r[e]>>31&&(r[e]^a)>>31,r[s]=a}};m.prototype.constructSUB2=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]);var r=t[s]-e;i.cpsrN=r>>31,i.cpsrZ=!(r&4294967295),i.cpsrC=t[s]>>>0>=e,i.cpsrV=t[s]>>31&&(t[s]^r)>>31,t[s]=r}};m.prototype.constructSUB3=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){t.mmu.waitPrefetch(r[15]);var a=r[e]-r[i];t.cpsrN=a>>31,t.cpsrZ=!(a&4294967295),t.cpsrC=r[e]>>>0>=r[i]>>>0,t.cpsrV=r[e]>>31!=r[i]>>31&&r[e]>>31!=a>>31,r[s]=a}};m.prototype.constructSWI=function(s){var e=this.cpu,i=e.gprs;return function(){e.irq.swi(s),e.mmu.waitPrefetch(i[15])}};m.prototype.constructTST=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]);var r=t[s]&t[e];i.cpsrN=r>>31,i.cpsrZ=!(r&4294967295)}};function R(){this.SP=13,this.LR=14,this.PC=15,this.MODE_ARM=0,this.MODE_THUMB=1,this.MODE_USER=16,this.MODE_FIQ=17,this.MODE_IRQ=18,this.MODE_SUPERVISOR=19,this.MODE_ABORT=23,this.MODE_UNDEFINED=27,this.MODE_SYSTEM=31,this.BANK_NONE=0,this.BANK_FIQ=1,this.BANK_IRQ=2,this.BANK_SUPERVISOR=3,this.BANK_ABORT=4,this.BANK_UNDEFINED=5,this.WORD_SIZE_ARM=4,this.WORD_SIZE_THUMB=2,this.BASE_RESET=0,this.BASE_UNDEF=4,this.BASE_SWI=8,this.BASE_PABT=12,this.BASE_DABT=16,this.BASE_IRQ=24,this.BASE_FIQ=28,this.armCompiler=new F(this),this.thumbCompiler=new m(this),this.generateConds(),this.gprs=new Int32Array(16)}R.prototype.resetCPU=function(s){for(var e=0;e<15;++e)this.gprs[e]=0;this.gprs[15]=s+4,this.loadInstruction=this.loadInstructionArm,this.execMode=0,this.instructionWidth=4,this.mode=31,this.cpsrI=!1,this.cpsrF=!1,this.cpsrV=!1,this.cpsrC=!1,this.cpsrZ=!1,this.cpsrN=!1,this.bankedRegisters=[new Int32Array(7),new Int32Array(7),new Int32Array(2),new Int32Array(2),new Int32Array(2),new Int32Array(2)],this.spsr=0,this.bankedSPSRs=new Int32Array(6),this.cycles=0,this.shifterOperand=0,this.shifterCarryOut=0,this.page=null,this.pageId=0,this.pageRegion=-1,this.instruction=null,this.irq.clear();var i=this.gprs,t=this.mmu;this.step=function(){var r=this.instruction||(this.instruction=this.loadInstruction(i[15]-this.instructionWidth));if(i[15]+=this.instructionWidth,this.conditionPassed=!0,r(),!r.writesPC)this.instruction!=null&&((r.next==null||r.next.page.invalid)&&(r.next=this.loadInstruction(i[15]-this.instructionWidth)),this.instruction=r.next);else if(this.conditionPassed){var a=i[15]&=4294967294;this.execMode==0?(t.wait32(a),t.waitPrefetch32(a)):(t.wait(a),t.waitPrefetch(a)),i[15]+=this.instructionWidth,r.fixedJump?this.instruction!=null&&((r.next==null||r.next.page.invalid)&&(r.next=this.loadInstruction(i[15]-this.instructionWidth)),this.instruction=r.next):this.instruction=null}else this.instruction=null;this.irq.updateTimers()}};R.prototype.freeze=function(){return{PC:this.gprs[15]-this.instructionWidth,SP:this.gprs[13],gprs:[this.gprs[0],this.gprs[1],this.gprs[2],this.gprs[3],this.gprs[4],this.gprs[5],this.gprs[6],this.gprs[7],this.gprs[8],this.gprs[9],this.gprs[10],this.gprs[11],this.gprs[12],this.gprs[13],this.gprs[14],this.gprs[15]],mode:this.mode,cpsrI:this.cpsrI,cpsrF:this.cpsrF,cpsrV:this.cpsrV,cpsrC:this.cpsrC,cpsrZ:this.cpsrZ,cpsrN:this.cpsrN,bankedRegisters:[[this.bankedRegisters[0][0],this.bankedRegisters[0][1],this.bankedRegisters[0][2],this.bankedRegisters[0][3],this.bankedRegisters[0][4],this.bankedRegisters[0][5],this.bankedRegisters[0][6]],[this.bankedRegisters[1][0],this.bankedRegisters[1][1],this.bankedRegisters[1][2],this.bankedRegisters[1][3],this.bankedRegisters[1][4],this.bankedRegisters[1][5],this.bankedRegisters[1][6]],[this.bankedRegisters[2][0],this.bankedRegisters[2][1]],[this.bankedRegisters[3][0],this.bankedRegisters[3][1]],[this.bankedRegisters[4][0],this.bankedRegisters[4][1]],[this.bankedRegisters[5][0],this.bankedRegisters[5][1]]],spsr:this.spsr,bankedSPSRs:[this.bankedSPSRs[0],this.bankedSPSRs[1],this.bankedSPSRs[2],this.bankedSPSRs[3],this.bankedSPSRs[4],this.bankedSPSRs[5]],cycles:this.cycles,instructionWidth:this.instructionWidth}};R.prototype.defrost=function(s){this.instruction=null,this.page=null,this.pageId=0,this.pageRegion=-1,this.gprs[0]=s.gprs[0],this.gprs[1]=s.gprs[1],this.gprs[2]=s.gprs[2],this.gprs[3]=s.gprs[3],this.gprs[4]=s.gprs[4],this.gprs[5]=s.gprs[5],this.gprs[6]=s.gprs[6],this.gprs[7]=s.gprs[7],this.gprs[8]=s.gprs[8],this.gprs[9]=s.gprs[9],this.gprs[10]=s.gprs[10],this.gprs[11]=s.gprs[11],this.gprs[12]=s.gprs[12],this.gprs[13]=s.gprs[13],this.gprs[14]=s.gprs[14],this.gprs[15]=s.gprs[15],this.mode=s.mode,this.cpsrI=s.cpsrI,this.cpsrF=s.cpsrF,this.cpsrV=s.cpsrV,this.cpsrC=s.cpsrC,this.cpsrZ=s.cpsrZ,this.cpsrN=s.cpsrN,this.bankedRegisters[0][0]=s.bankedRegisters[0][0],this.bankedRegisters[0][1]=s.bankedRegisters[0][1],this.bankedRegisters[0][2]=s.bankedRegisters[0][2],this.bankedRegisters[0][3]=s.bankedRegisters[0][3],this.bankedRegisters[0][4]=s.bankedRegisters[0][4],this.bankedRegisters[0][5]=s.bankedRegisters[0][5],this.bankedRegisters[0][6]=s.bankedRegisters[0][6],this.bankedRegisters[1][0]=s.bankedRegisters[1][0],this.bankedRegisters[1][1]=s.bankedRegisters[1][1],this.bankedRegisters[1][2]=s.bankedRegisters[1][2],this.bankedRegisters[1][3]=s.bankedRegisters[1][3],this.bankedRegisters[1][4]=s.bankedRegisters[1][4],this.bankedRegisters[1][5]=s.bankedRegisters[1][5],this.bankedRegisters[1][6]=s.bankedRegisters[1][6],this.bankedRegisters[2][0]=s.bankedRegisters[2][0],this.bankedRegisters[2][1]=s.bankedRegisters[2][1],this.bankedRegisters[3][0]=s.bankedRegisters[3][0],this.bankedRegisters[3][1]=s.bankedRegisters[3][1],this.bankedRegisters[4][0]=s.bankedRegisters[4][0],this.bankedRegisters[4][1]=s.bankedRegisters[4][1],this.bankedRegisters[5][0]=s.bankedRegisters[5][0],this.bankedRegisters[5][1]=s.bankedRegisters[5][1],this.spsr=s.spsr,this.bankedSPSRs[0]=s.bankedSPSRs[0],this.bankedSPSRs[1]=s.bankedSPSRs[1],this.bankedSPSRs[2]=s.bankedSPSRs[2],this.bankedSPSRs[3]=s.bankedSPSRs[3],this.bankedSPSRs[4]=s.bankedSPSRs[4],this.bankedSPSRs[5]=s.bankedSPSRs[5],this.cycles=s.cycles,this.instructionWidth=s.instructionWidth,this.loadInstruction=s.instructionWidth==2?this.loadInstructionThumb:this.loadInstructionArm,this.execMode=s.instructionWidth==2?1:0};R.prototype.fetchPage=function(s){var e=this.mmu,i=s>>>e.BASE_OFFSET,t=e.addressToPage(i,s&e.OFFSET_MASK);if(i==this.pageRegion){if(t==this.pageId&&!this.page.invalid)return;this.pageId=t}else this.pageMask=e.memory[i].PAGE_MASK,this.pageRegion=i,this.pageId=t;this.page=e.accessPage(i,t)};R.prototype.loadInstructionArm=function(s){var e=null;this.fetchPage(s);var i=(s&this.pageMask)>>2;if(e=this.page.arm[i],e)return e;var t=this.mmu.load32(s)>>>0;return e=this.compileArm(t),e.next=null,e.page=this.page,e.address=s,e.opcode=t,this.page.arm[i]=e,e};R.prototype.loadInstructionThumb=function(s){var e=null;this.fetchPage(s);var i=(s&this.pageMask)>>1;if(e=this.page.thumb[i],e)return e;var t=this.mmu.load16(s);return e=this.compileThumb(t),e.next=null,e.page=this.page,e.address=s,e.opcode=t,this.page.thumb[i]=e,e};R.prototype.selectBank=function(s){switch(s){case 16:case 31:return 0;case 17:return 1;case 18:return 2;case 19:return 3;case 23:return 4;case 27:return 5;default:throw new y("Invalid user mode "+s+" passed to selectBank")}};R.prototype.switchExecMode=function(s){this.execMode!=s&&(this.execMode=s,s==0?(this.instructionWidth=4,this.loadInstruction=this.loadInstructionArm):(this.instructionWidth=2,this.loadInstruction=this.loadInstructionThumb))};R.prototype.switchMode=function(s){if(s!=this.mode){if(s!=16||s!=31){var e=this.selectBank(s),i=this.selectBank(this.mode);if(e!=i){if(s==17||this.mode==17){var t=i==1?1:0,r=e==1?1:0;this.bankedRegisters[t][2]=this.gprs[8],this.bankedRegisters[t][3]=this.gprs[9],this.bankedRegisters[t][4]=this.gprs[10],this.bankedRegisters[t][5]=this.gprs[11],this.bankedRegisters[t][6]=this.gprs[12],this.gprs[8]=this.bankedRegisters[r][2],this.gprs[9]=this.bankedRegisters[r][3],this.gprs[10]=this.bankedRegisters[r][4],this.gprs[11]=this.bankedRegisters[r][5],this.gprs[12]=this.bankedRegisters[r][6]}this.bankedRegisters[i][0]=this.gprs[13],this.bankedRegisters[i][1]=this.gprs[14],this.gprs[13]=this.bankedRegisters[e][0],this.gprs[14]=this.bankedRegisters[e][1],this.bankedSPSRs[i]=this.spsr,this.spsr=this.bankedSPSRs[e]}}this.mode=s}};R.prototype.packCPSR=function(){return this.mode|this.execMode<<5|this.cpsrF<<6|this.cpsrI<<7|this.cpsrN<<31|this.cpsrZ<<30|this.cpsrC<<29|this.cpsrV<<28};R.prototype.unpackCPSR=function(s){this.switchMode(s&31),this.switchExecMode(!!(s&32)),this.cpsrF=s&64,this.cpsrI=s&128,this.cpsrN=s&2147483648,this.cpsrZ=s&1073741824,this.cpsrC=s&536870912,this.cpsrV=s&268435456,this.irq.testIRQ()};R.prototype.hasSPSR=function(){return this.mode!=31&&this.mode!=16};R.prototype.raiseIRQ=function(){if(!this.cpsrI){var s=this.packCPSR(),e=this.instructionWidth;this.switchMode(18),this.spsr=s,this.gprs[14]=this.gprs[15]-e+4,this.gprs[15]=this.BASE_IRQ+4,this.instruction=null,this.switchExecMode(0),this.cpsrI=!0}};R.prototype.raiseTrap=function(){var s=this.packCPSR(),e=this.instructionWidth;this.switchMode(19),this.spsr=s,this.gprs[14]=this.gprs[15]-e,this.gprs[15]=this.BASE_SWI+4,this.instruction=null,this.switchExecMode(0),this.cpsrI=!0};R.prototype.badOp=function(s){var e=function(){throw new y("Illegal instruction: 0x"+s.toString(16))};return e.writesPC=!0,e.fixedJump=!1,e};R.prototype.generateConds=function(){var s=this;this.conds=[function(){return s.conditionPassed=s.cpsrZ},function(){return s.conditionPassed=!s.cpsrZ},function(){return s.conditionPassed=s.cpsrC},function(){return s.conditionPassed=!s.cpsrC},function(){return s.conditionPassed=s.cpsrN},function(){return s.conditionPassed=!s.cpsrN},function(){return s.conditionPassed=s.cpsrV},function(){return s.conditionPassed=!s.cpsrV},function(){return s.conditionPassed=s.cpsrC&&!s.cpsrZ},function(){return s.conditionPassed=!s.cpsrC||s.cpsrZ},function(){return s.conditionPassed=!s.cpsrN==!s.cpsrV},function(){return s.conditionPassed=!s.cpsrN!=!s.cpsrV},function(){return s.conditionPassed=!s.cpsrZ&&!s.cpsrN==!s.cpsrV},function(){return s.conditionPassed=s.cpsrZ||!s.cpsrN!=!s.cpsrV},null,null]};R.prototype.barrelShiftImmediate=function(s,e,i){var t=this,r=this.gprs,a=this.badOp;switch(s){case 0:e?a=function(){t.shifterOperand=r[i]<>>e,t.shifterCarryOut=r[i]&1<>e,t.shifterCarryOut=r[i]&1<>>e|r[i]<<32-e,t.shifterCarryOut=r[i]&1<>>1,t.shifterCarryOut=r[i]&1};break}return a};R.prototype.compileArm=function(s){var e=this.badOp(s),i=s&234881024,t=this,r=this.gprs,a=this.conds[(s&4026531840)>>>28];if((s&268435440)==19922704){var c=s&15;e=this.armCompiler.constructBX(c,a),e.writesPC=!0,e.fixedJump=!1}else if(!(s&201326592)&&(i==33554432||(s&144)!=144)){var p=s&31457280,n=s&1048576,o=!1;if((p&25165824)==16777216&&!n){var v=s&4194304;if((s&11595776)==2158592){var c=s&15,x=s&255,w=(s&3840)>>7;x=x>>>w|x<<32-w,e=this.armCompiler.constructMSR(c,v,s,x,a),e.writesPC=!1}else if((s&12517376)==983040){var h=(s&61440)>>12;e=this.armCompiler.constructMRS(h,v,a),e.writesPC=h==15}}else{var f=(s&983040)>>16,h=(s&61440)>>12,l=s&96,c=s&15,C=function(){throw new y("BUG: invalid barrel shifter")};if(s&33554432){var x=s&255,V=(s&3840)>>7;V?C=this.armCompiler.constructAddressingMode1ImmediateRotate(x,V):C=this.armCompiler.constructAddressingMode1Immediate(x)}else if(s&16){var P=(s&3840)>>8;switch(o=!0,l){case 0:C=this.armCompiler.constructAddressingMode1LSL(P,c);break;case 32:C=this.armCompiler.constructAddressingMode1LSR(P,c);break;case 64:C=this.armCompiler.constructAddressingMode1ASR(P,c);break;case 96:C=this.armCompiler.constructAddressingMode1ROR(P,c);break}}else{var x=(s&3968)>>7;C=this.barrelShiftImmediate(l,x,c)}switch(p){case 0:n?e=this.armCompiler.constructANDS(h,f,C,a):e=this.armCompiler.constructAND(h,f,C,a);break;case 2097152:n?e=this.armCompiler.constructEORS(h,f,C,a):e=this.armCompiler.constructEOR(h,f,C,a);break;case 4194304:n?e=this.armCompiler.constructSUBS(h,f,C,a):e=this.armCompiler.constructSUB(h,f,C,a);break;case 6291456:n?e=this.armCompiler.constructRSBS(h,f,C,a):e=this.armCompiler.constructRSB(h,f,C,a);break;case 8388608:n?e=this.armCompiler.constructADDS(h,f,C,a):e=this.armCompiler.constructADD(h,f,C,a);break;case 10485760:n?e=this.armCompiler.constructADCS(h,f,C,a):e=this.armCompiler.constructADC(h,f,C,a);break;case 12582912:n?e=this.armCompiler.constructSBCS(h,f,C,a):e=this.armCompiler.constructSBC(h,f,C,a);break;case 14680064:n?e=this.armCompiler.constructRSCS(h,f,C,a):e=this.armCompiler.constructRSC(h,f,C,a);break;case 16777216:e=this.armCompiler.constructTST(h,f,C,a);break;case 18874368:e=this.armCompiler.constructTEQ(h,f,C,a);break;case 20971520:e=this.armCompiler.constructCMP(h,f,C,a);break;case 23068672:e=this.armCompiler.constructCMN(h,f,C,a);break;case 25165824:n?e=this.armCompiler.constructORRS(h,f,C,a):e=this.armCompiler.constructORR(h,f,C,a);break;case 27262976:n?e=this.armCompiler.constructMOVS(h,f,C,a):e=this.armCompiler.constructMOV(h,f,C,a);break;case 29360128:n?e=this.armCompiler.constructBICS(h,f,C,a):e=this.armCompiler.constructBIC(h,f,C,a);break;case 31457280:n?e=this.armCompiler.constructMVNS(h,f,C,a):e=this.armCompiler.constructMVN(h,f,C,a);break}e.writesPC=h==15}}else if((s&263196656)==16777360){var c=s&15,h=s>>12&15,f=s>>16&15;s&4194304?e=this.armCompiler.constructSWPB(h,f,c,a):e=this.armCompiler.constructSWP(h,f,c,a),e.writesPC=h==15}else switch(i){case 0:if((s&16777456)==144){var h=(s&983040)>>16,f=(s&61440)>>12,P=(s&3840)>>8,c=s&15;switch(s&15728640){case 0:e=this.armCompiler.constructMUL(h,P,c,a);break;case 1048576:e=this.armCompiler.constructMULS(h,P,c,a);break;case 2097152:e=this.armCompiler.constructMLA(h,f,P,c,a);break;case 3145728:e=this.armCompiler.constructMLAS(h,f,P,c,a);break;case 8388608:e=this.armCompiler.constructUMULL(h,f,P,c,a);break;case 9437184:e=this.armCompiler.constructUMULLS(h,f,P,c,a);break;case 10485760:e=this.armCompiler.constructUMLAL(h,f,P,c,a);break;case 11534336:e=this.armCompiler.constructUMLALS(h,f,P,c,a);break;case 12582912:e=this.armCompiler.constructSMULL(h,f,P,c,a);break;case 13631488:e=this.armCompiler.constructSMULLS(h,f,P,c,a);break;case 14680064:e=this.armCompiler.constructSMLAL(h,f,P,c,a);break;case 15728640:e=this.armCompiler.constructSMLALS(h,f,P,c,a);break}e.writesPC=h==15}else{var T=s&1048576,h=(s&61440)>>12,cr=(s&3840)>>4,ur=c=s&15,H=s&32,n=s&64,k=s&2097152,i=s&4194304,d;if(i){var x=ur|cr;d=this.armCompiler.constructAddressingMode23Immediate(s,x,a)}else d=this.armCompiler.constructAddressingMode23Register(s,c,a);d.writesPC=!!k&&f==15,(s&144)==144&&(T?H?n?e=this.armCompiler.constructLDRSH(h,d,a):e=this.armCompiler.constructLDRH(h,d,a):n&&(e=this.armCompiler.constructLDRSB(h,d,a)):!n&&H&&(e=this.armCompiler.constructSTRH(h,d,a))),e.writesPC=h==15||d.writesPC}break;case 67108864:case 100663296:var h=(s&61440)>>12,T=s&1048576,W=s&4194304,i=s&33554432,d=function(){throw new y("Unimplemented memory access: 0x"+s.toString(16))};if(~s&16777216&&(s&=4292870143),i){var c=s&15,l=s&96,K=(s&3968)>>7;l||K?(C=this.barrelShiftImmediate(l,K,c),d=this.armCompiler.constructAddressingMode2RegisterShifted(s,C,a)):d=this.armCompiler.constructAddressingMode23Register(s,c,a)}else{var M=s&4095;d=this.armCompiler.constructAddressingMode23Immediate(s,M,a)}T?W?e=this.armCompiler.constructLDRB(h,d,a):e=this.armCompiler.constructLDR(h,d,a):W?e=this.armCompiler.constructSTRB(h,d,a):e=this.armCompiler.constructSTR(h,d,a),e.writesPC=T&&(h==15||d.writesPC);break;case 134217728:var T=s&1048576,k=s&2097152,Q=s&4194304,pr=s&8388608,G=s&16777216,P=s&65535,f=(s&983040)>>16,d,x=0,M=0,B=!1;if(pr){G&&(x=4);for(var A=1,i=0;i<16;A<<=1,++i)P&A&&(k&&i==f&&!M&&(P&=~A,x+=4,B=!0),M+=4)}else{G||(x=4);for(var A=1,i=0;i<16;A<<=1,++i)P&A&&(k&&i==f&&!M&&(P&=~A,x+=4,B=!0),x-=4,M-=4)}k?d=this.armCompiler.constructAddressingMode4Writeback(x,M,f,B):d=this.armCompiler.constructAddressingMode4(x,f),T?(Q?e=this.armCompiler.constructLDMS(P,d,a):e=this.armCompiler.constructLDM(P,d,a),e.writesPC=!!(P&1<<15)):(Q?e=this.armCompiler.constructSTMS(P,d,a):e=this.armCompiler.constructSTM(P,d,a),e.writesPC=!1);break;case 167772160:var x=s&16777215;x&8388608&&(x|=4278190080),x<<=2;var nr=s&16777216;nr?e=this.armCompiler.constructBL(x,a):e=this.armCompiler.constructB(x,a),e.writesPC=!0,e.fixedJump=!0;break;case 201326592:break;case 234881024:if((s&251658240)==251658240){var x=s&16777215;e=this.armCompiler.constructSWI(x,a),e.writesPC=!1}break;default:throw new y("Bad opcode: 0x"+s.toString(16))}return e.execMode=0,e.fixedJump=e.fixedJump||!1,e};R.prototype.compileThumb=function(s){var e=this.badOp(s&65535),i=this,t=this.gprs;if((s&64512)==16384){var r=(s&56)>>3,a=s&7;switch(s&960){case 0:e=this.thumbCompiler.constructAND(a,r);break;case 64:e=this.thumbCompiler.constructEOR(a,r);break;case 128:e=this.thumbCompiler.constructLSL2(a,r);break;case 192:e=this.thumbCompiler.constructLSR2(a,r);break;case 256:e=this.thumbCompiler.constructASR2(a,r);break;case 320:e=this.thumbCompiler.constructADC(a,r);break;case 384:e=this.thumbCompiler.constructSBC(a,r);break;case 448:e=this.thumbCompiler.constructROR(a,r);break;case 512:e=this.thumbCompiler.constructTST(a,r);break;case 576:e=this.thumbCompiler.constructNEG(a,r);break;case 640:e=this.thumbCompiler.constructCMP2(a,r);break;case 704:e=this.thumbCompiler.constructCMN(a,r);break;case 768:e=this.thumbCompiler.constructORR(a,r);break;case 832:e=this.thumbCompiler.constructMUL(a,r);break;case 896:e=this.thumbCompiler.constructBIC(a,r);break;case 960:e=this.thumbCompiler.constructMVN(a,r);break}e.writesPC=!1}else if((s&64512)==17408){var r=(s&120)>>3,c=s&7,p=s&128,a=c|p>>4;switch(s&768){case 0:e=this.thumbCompiler.constructADD4(a,r),e.writesPC=a==15;break;case 256:e=this.thumbCompiler.constructCMP3(a,r),e.writesPC=!1;break;case 512:e=this.thumbCompiler.constructMOV3(a,r),e.writesPC=a==15;break;case 768:e=this.thumbCompiler.constructBX(a,r),e.writesPC=!0,e.fixedJump=!1;break}}else if((s&63488)==6144){var r=(s&448)>>6,c=(s&56)>>3,a=s&7;switch(s&1536){case 0:e=this.thumbCompiler.constructADD3(a,c,r);break;case 512:e=this.thumbCompiler.constructSUB3(a,c,r);break;case 1024:var n=(s&448)>>6;n?e=this.thumbCompiler.constructADD1(a,c,n):e=this.thumbCompiler.constructMOV2(a,c,r);break;case 1536:var n=(s&448)>>6;e=this.thumbCompiler.constructSUB1(a,c,n);break}e.writesPC=!1}else if(s&57344)if((s&57344)==8192){var n=s&255,c=(s&1792)>>8;switch(s&6144){case 0:e=this.thumbCompiler.constructMOV1(c,n);break;case 2048:e=this.thumbCompiler.constructCMP1(c,n);break;case 4096:e=this.thumbCompiler.constructADD2(c,n);break;case 6144:e=this.thumbCompiler.constructSUB2(c,n);break}e.writesPC=!1}else if((s&63488)==18432){var a=(s&1792)>>8,n=(s&255)<<2;e=this.thumbCompiler.constructLDR3(a,n),e.writesPC=!1}else if((s&61440)==20480){var a=s&7,c=(s&56)>>3,r=(s&448)>>6,o=s&3584;switch(o){case 0:e=this.thumbCompiler.constructSTR2(a,c,r);break;case 512:e=this.thumbCompiler.constructSTRH2(a,c,r);break;case 1024:e=this.thumbCompiler.constructSTRB2(a,c,r);break;case 1536:e=this.thumbCompiler.constructLDRSB(a,c,r);break;case 2048:e=this.thumbCompiler.constructLDR2(a,c,r);break;case 2560:e=this.thumbCompiler.constructLDRH2(a,c,r);break;case 3072:e=this.thumbCompiler.constructLDRB2(a,c,r);break;case 3584:e=this.thumbCompiler.constructLDRSH(a,c,r);break}e.writesPC=!1}else if((s&57344)==24576){var a=s&7,c=(s&56)>>3,n=(s&1984)>>4,v=s&4096;v&&(n>>=2);var x=s&2048;x?v?e=this.thumbCompiler.constructLDRB1(a,c,n):e=this.thumbCompiler.constructLDR1(a,c,n):v?e=this.thumbCompiler.constructSTRB1(a,c,n):e=this.thumbCompiler.constructSTR1(a,c,n),e.writesPC=!1}else if((s&62976)==46080){var w=!!(s&256),h=s&255;s&2048?(e=this.thumbCompiler.constructPOP(h,w),e.writesPC=w,e.fixedJump=!1):(e=this.thumbCompiler.constructPUSH(h,w),e.writesPC=!1)}else if(s&32768)switch(s&28672){case 0:var a=s&7,c=(s&56)>>3,n=(s&1984)>>5;s&2048?e=this.thumbCompiler.constructLDRH1(a,c,n):e=this.thumbCompiler.constructSTRH1(a,c,n),e.writesPC=!1;break;case 4096:var a=(s&1792)>>8,n=(s&255)<<2,x=s&2048;x?e=this.thumbCompiler.constructLDR4(a,n):e=this.thumbCompiler.constructSTR3(a,n),e.writesPC=!1;break;case 8192:var a=(s&1792)>>8,n=(s&255)<<2;s&2048?e=this.thumbCompiler.constructADD6(a,n):e=this.thumbCompiler.constructADD5(a,n),e.writesPC=!1;break;case 12288:if(!(s&3840)){var v=s&128,n=(s&127)<<2;v&&(n=-n),e=this.thumbCompiler.constructADD7(n),e.writesPC=!1}break;case 16384:var c=(s&1792)>>8,h=s&255;s&2048?e=this.thumbCompiler.constructLDMIA(c,h):e=this.thumbCompiler.constructSTMIA(c,h),e.writesPC=!1;break;case 20480:var f=(s&3840)>>8,n=s&255;if(f==15)e=this.thumbCompiler.constructSWI(n),e.writesPC=!1;else{s&128&&(n|=4294967040),n<<=1;var l=this.conds[f];e=this.thumbCompiler.constructB1(n,l),e.writesPC=!0,e.fixedJump=!0}break;case 24576:case 28672:var n=s&2047,C=s&6144;switch(C){case 0:n&1024&&(n|=4294965248),n<<=1,e=this.thumbCompiler.constructB2(n),e.writesPC=!0,e.fixedJump=!0;break;case 2048:break;case 4096:n&1024&&(n|=4294966272),n<<=12,e=this.thumbCompiler.constructBL1(n),e.writesPC=!1;break;case 6144:e=this.thumbCompiler.constructBL2(n),e.writesPC=!0,e.fixedJump=!1;break}break;default:throw new y("Undefined instruction: 0x"+s.toString(16))}else throw new y("Bad opcode: 0x"+s.toString(16));else{var a=s&7,r=(s&56)>>3,n=(s&1984)>>6;switch(s&6144){case 0:e=this.thumbCompiler.constructLSL1(a,r,n);break;case 2048:e=this.thumbCompiler.constructLSR1(a,r,n);break;case 4096:e=this.thumbCompiler.constructASR1(a,r,n);break;case 6144:break}e.writesPC=!1}return e.execMode=1,e.fixedJump=e.fixedJump||!1,e};var U=class{constructor(){this.BASE_OFFSET=24;this.OFFSET_MASK=16777215;this.core=new R,this.core.irq=this,this.core.mmu=this,this.resetMemory()}resetMemory(){this.memory=[];for(var e=0;e<256;e++){var i=10,t=524288;this.memory[e]={PAGE_MASK:(2<0?e:1}getPC(){return this.core.gprs[15]-this.core.instructionWidth}getSP(){return this.core.gprs[13]}isStable(){return!0}connectMemoryBus(e){this.bus=e}reset(){this.resetMemory(),this.core.resetCPU(0)}saveState(){return this.core.freeze()}loadState(e){this.core.defrost(e)}load8(e){return this.bus.read(e)<<24>>24}loadU8(e){return this.bus.read(e)&255}load16(e){return this.loadU16(e)<<16>>16}loadU16(e){return this.bus.read(e)|this.bus.read(e+1)<<8}load32(e){var i=this.bus.read(e)|this.bus.read(e+1)<<8|this.bus.read(e+2)<<16|this.bus.read(e+3)<<24;return i}store8(e,i){this.bus.write(e,i&255)}store16(e,i){this.bus.write(e,i&255),this.bus.write(e+1,i>>8&255)}store32(e,i){this.bus.write(e,i&255),this.bus.write(e+1,i>>8&255),this.bus.write(e+2,i>>16&255),this.bus.write(e+3,i>>24&255)}wait(e){++this.core.cycles}wait32(e){++this.core.cycles}waitSeq32(e){++this.core.cycles}waitMul(e){(e&4294967040)==4294967040||!(e&4294967040)?this.core.cycles+=1:(e&4294901760)==4294901760||!(e&4294901760)?this.core.cycles+=2:(e&4278190080)==4278190080||!(e&4278190080)?this.core.cycles+=3:this.core.cycles+=4}waitMulti32(e,i){this.core.cycles+=2}waitPrefetch(e){++this.core.cycles}waitPrefetch32(e){++this.core.cycles}addressToPage(e,i){return i>>this.memory[e].ICACHE_PAGE_BITS}accessPage(e,i){var t=this.memory[e],r=t.icache[i];return(!r||r.invalid)&&(r={thumb:new Array(1<>16)}clear(){}updateTimers(){}testIRQ(){}isThumb(){return this.core.instructionWidth==2}};var Fr=X([[S.A,0,1],[S.B,0,2],[S.GP_A,0,1],[S.GP_B,0,2],[S.SELECT,0,4],[S.START,0,8],[S.RIGHT,0,16],[S.LEFT,0,32],[S.UP,0,64],[S.DOWN,0,128]]),er=0,tr=524288,I=33554432,D=524288,O=67108864,_=256,hr=1e6,sr=4e6,Z=class extends q{constructor(){super();this.cpuFrequency=sr;this.canvasWidth=160;this.numTotalScanlines=256;this.numVisibleScanlines=128;this.cpuCyclesPerLine=Math.floor(sr/(256*60));this.defaultROMSize=512*1024;this.sampleRate=1;this.cpu=new U;this.ram=new Uint8Array(96*1024);this.ram16=new Uint16Array(this.ram.buffer);this.vidbase=0;this.brightness=255;this.read=L([[er,er+tr-1,tr-1,e=>this.rom?this.rom[e]:0],[I,I+D-1,D-1,e=>this.ram[e]],[O,O+_-1,_-1,(e,i)=>this.readIO(e)],[0,(1<<31)-1,0,(e,i)=>{throw new y(`Address read out of bounds: 0x${E(e)}`)}]]);this.write=L([[I,I+D-1,D-1,(e,i)=>{this.ram[e]=i}],[O,O+_-1,_-1,(e,i)=>{this.writeIO(e,i)}]]);this.connectCPUMemoryBus(this),this.handler=z(this.inputs,Fr)}connectVideo(e){super.connectVideo(e),this.pixels32=e,this.pixels8=new Uint8Array(e.buffer)}connectSerialIO(e){this.serial=e}reset(){super.reset(),this.serialOut=[],this.serialIn=[]}readIO(e){switch(e){case 0:return this.inputs[0];case 64:return(this.serial.byteAvailable()?128:0)|(this.serial.clearToSend()?64:0);case 68:let i=this.serialIn.shift();return i!=null?(this.serialOut.push(i),i.value):0;default:return 0}}writeIO(e,i){switch(e){case 0:break;case 72:this.serialOut.length>1&1048575,t=this.brightness<<24,r=0;r>5&31)<<11|(a>>10&31)<<19}}getDebugCategories(){return["CPU","Stack"]}getDebugInfo(e,i){switch(e){case"CPU":var t="",r=i.c;let c={2:"Thumb",4:"ARM"},p={15:"PC",14:"LR",13:"SP",12:"IP",11:"FP",9:"SB"};for(var a=0;a<16;a++)t+=N(p[a]||"",3)+N("r"+a,5)+" "+E(r.gprs[a],8)+` +import{H as j,q}from"./chunk-GKVIY6GD.js";import{D as J,H as Y,Q as y,T as S,U as z,W as X,Z as L,a as N,g as E}from"./chunk-YL2YTMD7.js";import"./chunk-RQFURXHW.js";var g;(function(o){o[o.MODE_ARM=0]="MODE_ARM",o[o.MODE_THUMB=1]="MODE_THUMB",o[o.MODE_USER=16]="MODE_USER",o[o.MODE_FIQ=17]="MODE_FIQ",o[o.MODE_IRQ=18]="MODE_IRQ",o[o.MODE_SUPERVISOR=19]="MODE_SUPERVISOR",o[o.MODE_ABORT=23]="MODE_ABORT",o[o.MODE_UNDEFINED=27]="MODE_UNDEFINED",o[o.MODE_SYSTEM=31]="MODE_SYSTEM"})(g||(g={}));var u;(function(t){t[t.SP=13]="SP",t[t.LR=14]="LR",t[t.PC=15]="PC"})(u||(u={}));var b;(function(l){l[l.BANK_NONE=0]="BANK_NONE",l[l.BANK_FIQ=1]="BANK_FIQ",l[l.BANK_IRQ=2]="BANK_IRQ",l[l.BANK_SUPERVISOR=3]="BANK_SUPERVISOR",l[l.BANK_ABORT=4]="BANK_ABORT",l[l.BANK_UNDEFINED=5]="BANK_UNDEFINED",l[l.WORD_SIZE_ARM=4]="WORD_SIZE_ARM",l[l.WORD_SIZE_THUMB=2]="WORD_SIZE_THUMB",l[l.BASE_RESET=0]="BASE_RESET",l[l.BASE_UNDEF=4]="BASE_UNDEF",l[l.BASE_SWI=8]="BASE_SWI",l[l.BASE_PABT=12]="BASE_PABT",l[l.BASE_DABT=16]="BASE_DABT",l[l.BASE_IRQ=24]="BASE_IRQ",l[l.BASE_FIQ=28]="BASE_FIQ"})(b||(b={}));var $=4026531840,rr=223,or=32;function F(s){this.cpu=s,this.addressingMode23Immediate=[function(e,i,t){var r=s.gprs,a=function(){var c=r[e];return(!t||t())&&(r[e]-=i),c};return a.writesPC=e==15,a},null,null,null,function(e,i,t){var r=s.gprs,a=function(){var c=r[e];return(!t||t())&&(r[e]+=i),c};return a.writesPC=e==15,a},null,null,null,function(e,i,t){var r=s.gprs,a=function(){return r[e]-i};return a.writesPC=!1,a},function(e,i,t){var r=s.gprs,a=function(){var c=r[e]-i;return(!t||t())&&(r[e]=c),c};return a.writesPC=e==15,a},null,null,function(e,i,t){var r=s.gprs,a=function(){return r[e]+i};return a.writesPC=!1,a},function(e,i,t){var r=s.gprs,a=function(){var c=r[e]+i;return(!t||t())&&(r[e]=c),c};return a.writesPC=e==15,a},null,null],this.addressingMode23Register=[function(e,i,t){var r=s.gprs,a=function(){var c=r[e];return(!t||t())&&(r[e]-=r[i]),c};return a.writesPC=e==15,a},null,null,null,function(e,i,t){var r=s.gprs,a=function(){var c=r[e];return(!t||t())&&(r[e]+=r[i]),c};return a.writesPC=e==15,a},null,null,null,function(e,i,t){var r=s.gprs,a=function(){return r[e]-r[i]};return a.writesPC=!1,a},function(e,i,t){var r=s.gprs,a=function(){var c=r[e]-r[i];return(!t||t())&&(r[e]=c),c};return a.writesPC=e==15,a},null,null,function(e,i,t){var r=s.gprs,a=function(){var c=r[e]+r[i];return c};return a.writesPC=!1,a},function(e,i,t){var r=s.gprs,a=function(){var c=r[e]+r[i];return(!t||t())&&(r[e]=c),c};return a.writesPC=e==15,a},null,null],this.addressingMode2RegisterShifted=[function(e,i,t){var r=s.gprs,a=function(){var c=r[e];return(!t||t())&&(i(),r[e]-=s.shifterOperand),c};return a.writesPC=e==15,a},null,null,null,function(e,i,t){var r=s.gprs,a=function(){var c=r[e];return(!t||t())&&(i(),r[e]+=s.shifterOperand),c};return a.writesPC=e==15,a},null,null,null,function(e,i,t){var r=s.gprs,a=function(){return i(),r[e]-s.shifterOperand};return a.writesPC=!1,a},function(e,i,t){var r=s.gprs,a=function(){i();var c=r[e]-s.shifterOperand;return(!t||t())&&(r[e]=c),c};return a.writesPC=e==15,a},null,null,function(e,i,t){var r=s.gprs,a=function(){return i(),r[e]+s.shifterOperand};return a.writesPC=!1,a},function(e,i,t){var r=s.gprs,a=function(){i();var c=r[e]+s.shifterOperand;return(!t||t())&&(r[e]=c),c};return a.writesPC=e==15,a},null,null]}F.prototype.constructAddressingMode1ASR=function(s,e){var i=this.cpu,t=i.gprs;return function(){++i.cycles;var r=t[s];s==15&&(r+=4),r&=255;var a=t[e];e==15&&(a+=4),r==0?(i.shifterOperand=a,i.shifterCarryOut=i.cpsrC):r<32?(i.shifterOperand=a>>r,i.shifterCarryOut=a&1<>31?(i.shifterOperand=4294967295,i.shifterCarryOut=2147483648):(i.shifterOperand=0,i.shifterCarryOut=0)}};F.prototype.constructAddressingMode1Immediate=function(s){var e=this.cpu;return function(){e.shifterOperand=s,e.shifterCarryOut=e.cpsrC}};F.prototype.constructAddressingMode1ImmediateRotate=function(s,e){var i=this.cpu;return function(){i.shifterOperand=s>>>e|s<<32-e,i.shifterCarryOut=i.shifterOperand>>31}};F.prototype.constructAddressingMode1LSL=function(s,e){var i=this.cpu,t=i.gprs;return function(){++i.cycles;var r=t[s];s==15&&(r+=4),r&=255;var a=t[e];e==15&&(a+=4),r==0?(i.shifterOperand=a,i.shifterCarryOut=i.cpsrC):r<32?(i.shifterOperand=a<>>r,i.shifterCarryOut=a&1<>31):(i.shifterOperand=0,i.shifterCarryOut=0)}};F.prototype.constructAddressingMode1ROR=function(s,e){var i=this.cpu,t=i.gprs;return function(){++i.cycles;var r=t[s];s==15&&(r+=4),r&=255;var a=t[e];e==15&&(a+=4);var c=r&31;r==0?(i.shifterOperand=a,i.shifterCarryOut=i.cpsrC):c?(i.shifterOperand=t[e]>>>c|t[e]<<32-c,i.shifterCarryOut=a&1<>31)}};F.prototype.constructAddressingMode23Immediate=function(s,e,i){var t=(s&983040)>>16;return this.addressingMode23Immediate[(s&27262976)>>21](t,e,i)};F.prototype.constructAddressingMode23Register=function(s,e,i){var t=(s&983040)>>16;return this.addressingMode23Register[(s&27262976)>>21](t,e,i)};F.prototype.constructAddressingMode2RegisterShifted=function(s,e,i){var t=(s&983040)>>16;return this.addressingMode2RegisterShifted[(s&27262976)>>21](t,e,i)};F.prototype.constructAddressingMode4=function(s,e){var i=this.cpu,t=i.gprs;return function(){var r=t[e]+s;return r}};F.prototype.constructAddressingMode4Writeback=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(c){var p=a[i]+s;return c&&t&&r.mmu.store32(a[i]+s-4,a[i]),a[i]+=e,p}};F.prototype.constructADC=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){if(r.mmu.waitPrefetch32(a[15]),!(t&&!t())){i();var c=(r.shifterOperand>>>0)+(r.cpsrC?1:0);a[s]=(a[e]>>>0)+c}}};F.prototype.constructADCS=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){if(r.mmu.waitPrefetch32(a[15]),!(t&&!t())){i();var c=(r.shifterOperand>>>0)+(r.cpsrC?1:0),p=(a[e]>>>0)+c;s==15&&r.hasSPSR()?r.unpackCPSR(r.spsr):(r.cpsrN=p>>31,r.cpsrZ=!(p&4294967295),r.cpsrC=p>4294967295,r.cpsrV=a[e]>>31==c>>31&&a[e]>>31!=p>>31&&c>>31!=p>>31),a[s]=p}}};F.prototype.constructADD=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){r.mmu.waitPrefetch32(a[15]),!(t&&!t())&&(i(),a[s]=(a[e]>>>0)+(r.shifterOperand>>>0))}};F.prototype.constructADDS=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){if(r.mmu.waitPrefetch32(a[15]),!(t&&!t())){i();var c=(a[e]>>>0)+(r.shifterOperand>>>0);s==15&&r.hasSPSR()?r.unpackCPSR(r.spsr):(r.cpsrN=c>>31,r.cpsrZ=!(c&4294967295),r.cpsrC=c>4294967295,r.cpsrV=a[e]>>31==r.shifterOperand>>31&&a[e]>>31!=c>>31&&r.shifterOperand>>31!=c>>31),a[s]=c}}};F.prototype.constructAND=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){r.mmu.waitPrefetch32(a[15]),!(t&&!t())&&(i(),a[s]=a[e]&r.shifterOperand)}};F.prototype.constructANDS=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){r.mmu.waitPrefetch32(a[15]),!(t&&!t())&&(i(),a[s]=a[e]&r.shifterOperand,s==15&&r.hasSPSR()?r.unpackCPSR(r.spsr):(r.cpsrN=a[s]>>31,r.cpsrZ=!(a[s]&4294967295),r.cpsrC=r.shifterCarryOut))}};F.prototype.constructB=function(s,e){var i=this.cpu,t=i.gprs;return function(){if(e&&!e()){i.mmu.waitPrefetch32(t[15]);return}i.mmu.waitPrefetch32(t[15]),t[15]+=s}};F.prototype.constructBIC=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){r.mmu.waitPrefetch32(a[15]),!(t&&!t())&&(i(),a[s]=a[e]&~r.shifterOperand)}};F.prototype.constructBICS=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){r.mmu.waitPrefetch32(a[15]),!(t&&!t())&&(i(),a[s]=a[e]&~r.shifterOperand,s==15&&r.hasSPSR()?r.unpackCPSR(r.spsr):(r.cpsrN=a[s]>>31,r.cpsrZ=!(a[s]&4294967295),r.cpsrC=r.shifterCarryOut))}};F.prototype.constructBL=function(s,e){var i=this.cpu,t=i.gprs;return function(){if(e&&!e()){i.mmu.waitPrefetch32(t[15]);return}i.mmu.waitPrefetch32(t[15]),t[14]=t[15]-4,t[15]+=s}};F.prototype.constructBX=function(s,e){var i=this.cpu,t=i.gprs;return function(){if(e&&!e()){i.mmu.waitPrefetch32(t[15]);return}i.mmu.waitPrefetch32(t[15]),i.switchExecMode(t[s]&1),t[15]=t[s]&4294967294}};F.prototype.constructCMN=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){if(r.mmu.waitPrefetch32(a[15]),!(t&&!t())){i();var c=(a[e]>>>0)+(r.shifterOperand>>>0);r.cpsrN=c>>31,r.cpsrZ=!(c&4294967295),r.cpsrC=c>4294967295,r.cpsrV=a[e]>>31==r.shifterOperand>>31&&a[e]>>31!=c>>31&&r.shifterOperand>>31!=c>>31}}};F.prototype.constructCMP=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){if(r.mmu.waitPrefetch32(a[15]),!(t&&!t())){i();var c=a[e]-r.shifterOperand;r.cpsrN=c>>31,r.cpsrZ=!(c&4294967295),r.cpsrC=a[e]>>>0>=r.shifterOperand>>>0,r.cpsrV=a[e]>>31!=r.shifterOperand>>31&&a[e]>>31!=c>>31}}};F.prototype.constructEOR=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){r.mmu.waitPrefetch32(a[15]),!(t&&!t())&&(i(),a[s]=a[e]^r.shifterOperand)}};F.prototype.constructEORS=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){r.mmu.waitPrefetch32(a[15]),!(t&&!t())&&(i(),a[s]=a[e]^r.shifterOperand,s==15&&r.hasSPSR()?r.unpackCPSR(r.spsr):(r.cpsrN=a[s]>>31,r.cpsrZ=!(a[s]&4294967295),r.cpsrC=r.shifterCarryOut))}};F.prototype.constructLDM=function(s,e,i){var t=this.cpu,r=t.gprs,a=t.mmu;return function(){if(a.waitPrefetch32(r[15]),!(i&&!i())){var c=e(!1),p=0,n,o;for(n=s,o=0;n;n>>=1,++o)n&1&&(r[o]=a.load32(c&4294967292),c+=4,++p);a.waitMulti32(c,p),++t.cycles}}};F.prototype.constructLDMS=function(s,e,i){var t=this.cpu,r=t.gprs,a=t.mmu;return function(){if(a.waitPrefetch32(r[15]),!(i&&!i())){var c=e(!1),p=0,n=t.mode;t.switchMode(31);var o,v;for(o=s,v=0;o;o>>=1,++v)o&1&&(r[v]=a.load32(c&4294967292),c+=4,++p);t.switchMode(n),a.waitMulti32(c,p),++t.cycles}}};F.prototype.constructLDR=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){if(t.mmu.waitPrefetch32(r[15]),!(i&&!i())){var a=e();r[s]=t.mmu.load32(a),t.mmu.wait32(a),++t.cycles}}};F.prototype.constructLDRB=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){if(t.mmu.waitPrefetch32(r[15]),!(i&&!i())){var a=e();r[s]=t.mmu.loadU8(a),t.mmu.wait(a),++t.cycles}}};F.prototype.constructLDRH=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){if(t.mmu.waitPrefetch32(r[15]),!(i&&!i())){var a=e();r[s]=t.mmu.loadU16(a),t.mmu.wait(a),++t.cycles}}};F.prototype.constructLDRSB=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){if(t.mmu.waitPrefetch32(r[15]),!(i&&!i())){var a=e();r[s]=t.mmu.load8(a),t.mmu.wait(a),++t.cycles}}};F.prototype.constructLDRSH=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){if(t.mmu.waitPrefetch32(r[15]),!(i&&!i())){var a=e();r[s]=t.mmu.load16(a),t.mmu.wait(a),++t.cycles}}};F.prototype.constructMLA=function(s,e,i,t,r){var a=this.cpu,c=a.gprs;return function(){if(a.mmu.waitPrefetch32(c[15]),!(r&&!r()))if(++a.cycles,a.mmu.waitMul(i),c[t]&4294901760&&c[i]&4294901760){var p=(c[t]&4294901760)*c[i]&4294967295,n=(c[t]&65535)*c[i]&4294967295;c[s]=p+n+c[e]&4294967295}else c[s]=c[t]*c[i]+c[e]}};F.prototype.constructMLAS=function(s,e,i,t,r){var a=this.cpu,c=a.gprs;return function(){if(a.mmu.waitPrefetch32(c[15]),!(r&&!r())){if(++a.cycles,a.mmu.waitMul(i),c[t]&4294901760&&c[i]&4294901760){var p=(c[t]&4294901760)*c[i]&4294967295,n=(c[t]&65535)*c[i]&4294967295;c[s]=p+n+c[e]&4294967295}else c[s]=c[t]*c[i]+c[e];a.cpsrN=c[s]>>31,a.cpsrZ=!(c[s]&4294967295)}}};F.prototype.constructMOV=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){r.mmu.waitPrefetch32(a[15]),!(t&&!t())&&(i(),a[s]=r.shifterOperand)}};F.prototype.constructMOVS=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){r.mmu.waitPrefetch32(a[15]),!(t&&!t())&&(i(),a[s]=r.shifterOperand,s==15&&r.hasSPSR()?r.unpackCPSR(r.spsr):(r.cpsrN=a[s]>>31,r.cpsrZ=!(a[s]&4294967295),r.cpsrC=r.shifterCarryOut))}};F.prototype.constructMRS=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){t.mmu.waitPrefetch32(r[15]),!(i&&!i())&&(e?r[s]=t.spsr:r[s]=t.packCPSR())}};F.prototype.constructMSR=function(s,e,i,t,r){var a=this.cpu,c=a.gprs,p=i&65536,n=i&524288;return function(){if(a.mmu.waitPrefetch32(c[15]),!(r&&!r())){var o;i&33554432?o=t:o=c[s];var v=(p?255:0)|(n?4278190080:0);e?(v&=$|rr|or,a.spsr=a.spsr&~v|o&v):(v&$&&(a.cpsrN=o>>31,a.cpsrZ=o&1073741824,a.cpsrC=o&536870912,a.cpsrV=o&268435456),a.mode!=16&&v&rr&&(a.switchMode(o&15|16),a.cpsrI=o&128,a.cpsrF=o&64))}}};F.prototype.constructMUL=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){if(r.mmu.waitPrefetch32(a[15]),!(t&&!t()))if(r.mmu.waitMul(a[e]),a[i]&4294901760&&a[e]&4294901760){var c=(a[i]&4294901760)*a[e]|0,p=(a[i]&65535)*a[e]|0;a[s]=c+p}else a[s]=a[i]*a[e]}};F.prototype.constructMULS=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){if(r.mmu.waitPrefetch32(a[15]),!(t&&!t())){if(r.mmu.waitMul(a[e]),a[i]&4294901760&&a[e]&4294901760){var c=(a[i]&4294901760)*a[e]|0,p=(a[i]&65535)*a[e]|0;a[s]=c+p}else a[s]=a[i]*a[e];r.cpsrN=a[s]>>31,r.cpsrZ=!(a[s]&4294967295)}}};F.prototype.constructMVN=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){r.mmu.waitPrefetch32(a[15]),!(t&&!t())&&(i(),a[s]=~r.shifterOperand)}};F.prototype.constructMVNS=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){r.mmu.waitPrefetch32(a[15]),!(t&&!t())&&(i(),a[s]=~r.shifterOperand,s==15&&r.hasSPSR()?r.unpackCPSR(r.spsr):(r.cpsrN=a[s]>>31,r.cpsrZ=!(a[s]&4294967295),r.cpsrC=r.shifterCarryOut))}};F.prototype.constructORR=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){r.mmu.waitPrefetch32(a[15]),!(t&&!t())&&(i(),a[s]=a[e]|r.shifterOperand)}};F.prototype.constructORRS=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){r.mmu.waitPrefetch32(a[15]),!(t&&!t())&&(i(),a[s]=a[e]|r.shifterOperand,s==15&&r.hasSPSR()?r.unpackCPSR(r.spsr):(r.cpsrN=a[s]>>31,r.cpsrZ=!(a[s]&4294967295),r.cpsrC=r.shifterCarryOut))}};F.prototype.constructRSB=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){r.mmu.waitPrefetch32(a[15]),!(t&&!t())&&(i(),a[s]=r.shifterOperand-a[e])}};F.prototype.constructRSBS=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){if(r.mmu.waitPrefetch32(a[15]),!(t&&!t())){i();var c=r.shifterOperand-a[e];s==15&&r.hasSPSR()?r.unpackCPSR(r.spsr):(r.cpsrN=c>>31,r.cpsrZ=!(c&4294967295),r.cpsrC=r.shifterOperand>>>0>=a[e]>>>0,r.cpsrV=r.shifterOperand>>31!=a[e]>>31&&r.shifterOperand>>31!=c>>31),a[s]=c}}};F.prototype.constructRSC=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){if(r.mmu.waitPrefetch32(a[15]),!(t&&!t())){i();var c=(a[e]>>>0)+(r.cpsrC?0:1);a[s]=(r.shifterOperand>>>0)-c}}};F.prototype.constructRSCS=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){if(r.mmu.waitPrefetch32(a[15]),!(t&&!t())){i();var c=(a[e]>>>0)+(r.cpsrC?0:1),p=(r.shifterOperand>>>0)-c;s==15&&r.hasSPSR()?r.unpackCPSR(r.spsr):(r.cpsrN=p>>31,r.cpsrZ=!(p&4294967295),r.cpsrC=r.shifterOperand>>>0>=p>>>0,r.cpsrV=r.shifterOperand>>31!=c>>31&&r.shifterOperand>>31!=p>>31),a[s]=p}}};F.prototype.constructSBC=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){if(r.mmu.waitPrefetch32(a[15]),!(t&&!t())){i();var c=(r.shifterOperand>>>0)+(r.cpsrC?0:1);a[s]=(a[e]>>>0)-c}}};F.prototype.constructSBCS=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){if(r.mmu.waitPrefetch32(a[15]),!(t&&!t())){i();var c=(r.shifterOperand>>>0)+(r.cpsrC?0:1),p=(a[e]>>>0)-c;s==15&&r.hasSPSR()?r.unpackCPSR(r.spsr):(r.cpsrN=p>>31,r.cpsrZ=!(p&4294967295),r.cpsrC=a[e]>>>0>=p>>>0,r.cpsrV=a[e]>>31!=c>>31&&a[e]>>31!=p>>31),a[s]=p}}};F.prototype.constructSMLAL=function(s,e,i,t,r){var a=this.cpu,c=1/4294967296,p=a.gprs;return function(){if(a.mmu.waitPrefetch32(p[15]),!(r&&!r())){a.cycles+=2,a.mmu.waitMul(i);var n=(p[t]&4294901760)*p[i],o=(p[t]&65535)*p[i],v=(p[e]>>>0)+n+o;p[e]=v,p[s]+=Math.floor(v*c)}}};F.prototype.constructSMLALS=function(s,e,i,t,r){var a=this.cpu,c=1/4294967296,p=a.gprs;return function(){if(a.mmu.waitPrefetch32(p[15]),!(r&&!r())){a.cycles+=2,a.mmu.waitMul(i);var n=(p[t]&4294901760)*p[i],o=(p[t]&65535)*p[i],v=(p[e]>>>0)+n+o;p[e]=v,p[s]+=Math.floor(v*c),a.cpsrN=p[s]>>31,a.cpsrZ=!(p[s]&4294967295||p[e]&4294967295)}}};F.prototype.constructSMULL=function(s,e,i,t,r){var a=this.cpu,c=1/4294967296,p=a.gprs;return function(){if(a.mmu.waitPrefetch32(p[15]),!(r&&!r())){++a.cycles,a.mmu.waitMul(p[i]);var n=((p[t]&4294901760)>>0)*(p[i]>>0),o=((p[t]&65535)>>0)*(p[i]>>0);p[e]=(n&4294967295)+(o&4294967295)&4294967295,p[s]=Math.floor(n*c+o*c)}}};F.prototype.constructSMULLS=function(s,e,i,t,r){var a=this.cpu,c=1/4294967296,p=a.gprs;return function(){if(a.mmu.waitPrefetch32(p[15]),!(r&&!r())){++a.cycles,a.mmu.waitMul(p[i]);var n=((p[t]&4294901760)>>0)*(p[i]>>0),o=((p[t]&65535)>>0)*(p[i]>>0);p[e]=(n&4294967295)+(o&4294967295)&4294967295,p[s]=Math.floor(n*c+o*c),a.cpsrN=p[s]>>31,a.cpsrZ=!(p[s]&4294967295||p[e]&4294967295)}}};F.prototype.constructSTM=function(s,e,i){var t=this.cpu,r=t.gprs,a=t.mmu;return function(){if(i&&!i()){a.waitPrefetch32(r[15]);return}a.wait32(r[15]);var c=e(!0),p=0,n,o;for(n=s,o=0;n;n>>=1,++o)n&1&&(a.store32(c,r[o]),c+=4,++p);a.waitMulti32(c,p)}};F.prototype.constructSTMS=function(s,e,i){var t=this.cpu,r=t.gprs,a=t.mmu;return function(){if(i&&!i()){a.waitPrefetch32(r[15]);return}a.wait32(r[15]);var c=t.mode,p=e(!0),n=0,o,v;for(t.switchMode(31),o=s,v=0;o;o>>=1,++v)o&1&&(a.store32(p,r[v]),p+=4,++n);t.switchMode(c),a.waitMulti32(p,n)}};F.prototype.constructSTR=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){if(i&&!i()){t.mmu.waitPrefetch32(r[15]);return}var a=e();t.mmu.store32(a,r[s]),t.mmu.wait32(a),t.mmu.wait32(r[15])}};F.prototype.constructSTRB=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){if(i&&!i()){t.mmu.waitPrefetch32(r[15]);return}var a=e();t.mmu.store8(a,r[s]),t.mmu.wait(a),t.mmu.wait32(r[15])}};F.prototype.constructSTRH=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){if(i&&!i()){t.mmu.waitPrefetch32(r[15]);return}var a=e();t.mmu.store16(a,r[s]),t.mmu.wait(a),t.mmu.wait32(r[15])}};F.prototype.constructSUB=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){r.mmu.waitPrefetch32(a[15]),!(t&&!t())&&(i(),a[s]=a[e]-r.shifterOperand)}};F.prototype.constructSUBS=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){if(r.mmu.waitPrefetch32(a[15]),!(t&&!t())){i();var c=a[e]-r.shifterOperand;s==15&&r.hasSPSR()?r.unpackCPSR(r.spsr):(r.cpsrN=c>>31,r.cpsrZ=!(c&4294967295),r.cpsrC=a[e]>>>0>=r.shifterOperand>>>0,r.cpsrV=a[e]>>31!=r.shifterOperand>>31&&a[e]>>31!=c>>31),a[s]=c}}};F.prototype.constructSWI=function(s,e){var i=this.cpu,t=i.gprs;return function(){if(e&&!e()){i.mmu.waitPrefetch32(t[15]);return}i.irq.swi32(s),i.mmu.waitPrefetch32(t[15])}};F.prototype.constructSWP=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){if(r.mmu.waitPrefetch32(a[15]),!(t&&!t())){r.mmu.wait32(a[e]),r.mmu.wait32(a[e]);var c=r.mmu.load32(a[e]);r.mmu.store32(a[e],a[i]),a[s]=c,++r.cycles}}};F.prototype.constructSWPB=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){if(r.mmu.waitPrefetch32(a[15]),!(t&&!t())){r.mmu.wait(a[e]),r.mmu.wait(a[e]);var c=r.mmu.loadU8(a[e]);r.mmu.store8(a[e],a[i]),a[s]=c,++r.cycles}}};F.prototype.constructTEQ=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){if(r.mmu.waitPrefetch32(a[15]),!(t&&!t())){i();var c=a[e]^r.shifterOperand;r.cpsrN=c>>31,r.cpsrZ=!(c&4294967295),r.cpsrC=r.shifterCarryOut}}};F.prototype.constructTST=function(s,e,i,t){var r=this.cpu,a=r.gprs;return function(){if(r.mmu.waitPrefetch32(a[15]),!(t&&!t())){i();var c=a[e]&r.shifterOperand;r.cpsrN=c>>31,r.cpsrZ=!(c&4294967295),r.cpsrC=r.shifterCarryOut}}};F.prototype.constructUMLAL=function(s,e,i,t,r){var a=this.cpu,c=1/4294967296,p=a.gprs;return function(){if(a.mmu.waitPrefetch32(p[15]),!(r&&!r())){a.cycles+=2,a.mmu.waitMul(i);var n=((p[t]&4294901760)>>>0)*(p[i]>>>0),o=(p[t]&65535)*(p[i]>>>0),v=(p[e]>>>0)+n+o;p[e]=v,p[s]+=v*c}}};F.prototype.constructUMLALS=function(s,e,i,t,r){var a=this.cpu,c=1/4294967296,p=a.gprs;return function(){if(a.mmu.waitPrefetch32(p[15]),!(r&&!r())){a.cycles+=2,a.mmu.waitMul(i);var n=((p[t]&4294901760)>>>0)*(p[i]>>>0),o=(p[t]&65535)*(p[i]>>>0),v=(p[e]>>>0)+n+o;p[e]=v,p[s]+=v*c,a.cpsrN=p[s]>>31,a.cpsrZ=!(p[s]&4294967295||p[e]&4294967295)}}};F.prototype.constructUMULL=function(s,e,i,t,r){var a=this.cpu,c=1/4294967296,p=a.gprs;return function(){if(a.mmu.waitPrefetch32(p[15]),!(r&&!r())){++a.cycles,a.mmu.waitMul(p[i]);var n=((p[t]&4294901760)>>>0)*(p[i]>>>0),o=((p[t]&65535)>>>0)*(p[i]>>>0);p[e]=(n&4294967295)+(o&4294967295)&4294967295,p[s]=n*c+o*c>>>0}}};F.prototype.constructUMULLS=function(s,e,i,t,r){var a=this.cpu,c=1/4294967296,p=a.gprs;return function(){if(a.mmu.waitPrefetch32(p[15]),!(r&&!r())){++a.cycles,a.mmu.waitMul(p[i]);var n=((p[t]&4294901760)>>>0)*(p[i]>>>0),o=((p[t]&65535)>>>0)*(p[i]>>>0);p[e]=(n&4294967295)+(o&4294967295)&4294967295,p[s]=n*c+o*c>>>0,a.cpsrN=p[s]>>31,a.cpsrZ=!(p[s]&4294967295||p[e]&4294967295)}}};function m(s){this.cpu=s}m.prototype.constructADC=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]);var r=(t[e]>>>0)+(i.cpsrC?1:0),a=t[s],c=(a>>>0)+r,p=a>>31,n=c>>31,o=r>>31;i.cpsrN=n,i.cpsrZ=!(c&4294967295),i.cpsrC=c>4294967295,i.cpsrV=p==o&&p!=n&&o!=n,t[s]=c}};m.prototype.constructADD1=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){t.mmu.waitPrefetch(r[15]);var a=(r[e]>>>0)+i;t.cpsrN=a>>31,t.cpsrZ=!(a&4294967295),t.cpsrC=a>4294967295,t.cpsrV=!(r[e]>>31)&&(r[e]>>31^a)>>31&&a>>31,r[s]=a}};m.prototype.constructADD2=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]);var r=(t[s]>>>0)+e;i.cpsrN=r>>31,i.cpsrZ=!(r&4294967295),i.cpsrC=r>4294967295,i.cpsrV=!(t[s]>>31)&&(t[s]^r)>>31&&(e^r)>>31,t[s]=r}};m.prototype.constructADD3=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){t.mmu.waitPrefetch(r[15]);var a=(r[e]>>>0)+(r[i]>>>0);t.cpsrN=a>>31,t.cpsrZ=!(a&4294967295),t.cpsrC=a>4294967295,t.cpsrV=!((r[e]^r[i])>>31)&&(r[e]^a)>>31&&(r[i]^a)>>31,r[s]=a}};m.prototype.constructADD4=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]),t[s]+=t[e]}};m.prototype.constructADD5=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]),t[s]=(t[15]&4294967292)+e}};m.prototype.constructADD6=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]),t[s]=t[13]+e}};m.prototype.constructADD7=function(s){var e=this.cpu,i=e.gprs;return function(){e.mmu.waitPrefetch(i[15]),i[13]+=s}};m.prototype.constructAND=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]),t[s]=t[s]&t[e],i.cpsrN=t[s]>>31,i.cpsrZ=!(t[s]&4294967295)}};m.prototype.constructASR1=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){t.mmu.waitPrefetch(r[15]),i==0?(t.cpsrC=r[e]>>31,t.cpsrC?r[s]=4294967295:r[s]=0):(t.cpsrC=r[e]&1<>i),t.cpsrN=r[s]>>31,t.cpsrZ=!(r[s]&4294967295)}};m.prototype.constructASR2=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]);var r=t[e]&255;r&&(r<32?(i.cpsrC=t[s]&1<>=r):(i.cpsrC=t[s]>>31,i.cpsrC?t[s]=4294967295:t[s]=0)),i.cpsrN=t[s]>>31,i.cpsrZ=!(t[s]&4294967295)}};m.prototype.constructB1=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]),e()&&(t[15]+=s)}};m.prototype.constructB2=function(s){var e=this.cpu,i=e.gprs;return function(){e.mmu.waitPrefetch(i[15]),i[15]+=s}};m.prototype.constructBIC=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]),t[s]=t[s]&~t[e],i.cpsrN=t[s]>>31,i.cpsrZ=!(t[s]&4294967295)}};m.prototype.constructBL1=function(s){var e=this.cpu,i=e.gprs;return function(){e.mmu.waitPrefetch(i[15]),i[14]=i[15]+s}};m.prototype.constructBL2=function(s){var e=this.cpu,i=e.gprs;return function(){e.mmu.waitPrefetch(i[15]);var t=i[15];i[15]=i[14]+(s<<1),i[14]=t-1}};m.prototype.constructBX=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]),i.switchExecMode(t[e]&1);var r=0;e==15&&(r=t[e]&2),t[15]=t[e]&4294967294-r}};m.prototype.constructCMN=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]);var r=(t[s]>>>0)+(t[e]>>>0);i.cpsrN=r>>31,i.cpsrZ=!(r&4294967295),i.cpsrC=r>4294967295,i.cpsrV=t[s]>>31==t[e]>>31&&t[s]>>31!=r>>31&&t[e]>>31!=r>>31}};m.prototype.constructCMP1=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]);var r=t[s]-e;i.cpsrN=r>>31,i.cpsrZ=!(r&4294967295),i.cpsrC=t[s]>>>0>=e,i.cpsrV=t[s]>>31&&(t[s]^r)>>31}};m.prototype.constructCMP2=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]);var r=t[s],a=t[e],c=r-a,p=c>>31,n=r>>31;i.cpsrN=p,i.cpsrZ=!(c&4294967295),i.cpsrC=r>>>0>=a>>>0,i.cpsrV=n!=a>>31&&n!=p}};m.prototype.constructCMP3=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]);var r=t[s]-t[e];i.cpsrN=r>>31,i.cpsrZ=!(r&4294967295),i.cpsrC=t[s]>>>0>=t[e]>>>0,i.cpsrV=(t[s]^t[e])>>31&&(t[s]^r)>>31}};m.prototype.constructEOR=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]),t[s]=t[s]^t[e],i.cpsrN=t[s]>>31,i.cpsrZ=!(t[s]&4294967295)}};m.prototype.constructLDMIA=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]);var r=t[s],a=0,c,p;for(c=1,p=0;p<8;c<<=1,++p)e&c&&(t[p]=i.mmu.load32(r),r+=4,++a);i.mmu.waitMulti32(r,a),1<>31,t.cpsrZ=!(r[s]&4294967295)}};m.prototype.constructLSL2=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]);var r=t[e]&255;r&&(r<32?(i.cpsrC=t[s]&1<<32-r,t[s]<<=r):(r>32?i.cpsrC=0:i.cpsrC=t[s]&1,t[s]=0)),i.cpsrN=t[s]>>31,i.cpsrZ=!(t[s]&4294967295)}};m.prototype.constructLSR1=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){t.mmu.waitPrefetch(r[15]),i==0?(t.cpsrC=r[e]>>31,r[s]=0):(t.cpsrC=r[e]&1<>>i),t.cpsrN=0,t.cpsrZ=!(r[s]&4294967295)}};m.prototype.constructLSR2=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]);var r=t[e]&255;r&&(r<32?(i.cpsrC=t[s]&1<>>=r):(r>32?i.cpsrC=0:i.cpsrC=t[s]>>31,t[s]=0)),i.cpsrN=t[s]>>31,i.cpsrZ=!(t[s]&4294967295)}};m.prototype.constructMOV1=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]),t[s]=e,i.cpsrN=e>>31,i.cpsrZ=!(e&4294967295)}};m.prototype.constructMOV2=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){t.mmu.waitPrefetch(r[15]);var a=r[e];t.cpsrN=a>>31,t.cpsrZ=!(a&4294967295),t.cpsrC=0,t.cpsrV=0,r[s]=a}};m.prototype.constructMOV3=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]),t[s]=t[e]}};m.prototype.constructMUL=function(s,e){var i=this.cpu,t=i.gprs;return function(){if(i.mmu.waitPrefetch(t[15]),i.mmu.waitMul(t[e]),t[e]&4294901760&&t[s]&4294901760){var r=(t[s]&4294901760)*t[e]&4294967295,a=(t[s]&65535)*t[e]&4294967295;t[s]=r+a&4294967295}else t[s]*=t[e];i.cpsrN=t[s]>>31,i.cpsrZ=!(t[s]&4294967295)}};m.prototype.constructMVN=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]),t[s]=~t[e],i.cpsrN=t[s]>>31,i.cpsrZ=!(t[s]&4294967295)}};m.prototype.constructNEG=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]);var r=-t[e];i.cpsrN=r>>31,i.cpsrZ=!(r&4294967295),i.cpsrC=0>=r>>>0,i.cpsrV=t[e]>>31&&r>>31,t[s]=r}};m.prototype.constructORR=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]),t[s]=t[s]|t[e],i.cpsrN=t[s]>>31,i.cpsrZ=!(t[s]&4294967295)}};m.prototype.constructPOP=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]),++i.cycles;var r=t[13],a=0,c,p;for(c=1,p=0;p<8;c<<=1,++p)s&c&&(i.mmu.waitSeq32(r),t[p]=i.mmu.load32(r),r+=4,++a);e&&(t[15]=i.mmu.load32(r)&4294967294,r+=4,++a),i.mmu.waitMulti32(r,a),t[13]=r}};m.prototype.constructPUSH=function(s,e){var i=this.cpu,t=i.gprs;return function(){var r=t[13]-4,a=0;i.mmu.waitPrefetch(t[15]),e&&(i.mmu.store32(r,t[14]),r-=4,++a);var c,p;for(c=128,p=7;c;c>>=1,--p)if(s&c){i.mmu.store32(r,t[p]),r-=4,++a;break}for(c>>=1,--p;c;c>>=1,--p)s&c&&(i.mmu.store32(r,t[p]),r-=4,++a);i.mmu.waitMulti32(r,a),t[13]=r+4}};m.prototype.constructROR=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]);var r=t[e]&255;if(r){var a=r&31;a>0?(i.cpsrC=t[s]&1<>>a|t[s]<<32-a):i.cpsrC=t[s]>>31}i.cpsrN=t[s]>>31,i.cpsrZ=!(t[s]&4294967295)}};m.prototype.constructSBC=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]);var r=(t[e]>>>0)+(i.cpsrC?0:1),a=(t[s]>>>0)-r;i.cpsrN=a>>31,i.cpsrZ=!(a&4294967295),i.cpsrC=t[s]>>>0>=a>>>0,i.cpsrV=(t[s]^r)>>31&&(t[s]^a)>>31,t[s]=a}};m.prototype.constructSTMIA=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.wait(t[15]);var r=t[s],a=0,c,p;for(c=1,p=0;p<8;c<<=1,++p)if(e&c){i.mmu.store32(r,t[p]),r+=4,++a;break}for(c<<=1,++p;p<8;c<<=1,++p)e&c&&(i.mmu.store32(r,t[p]),r+=4,++a);i.mmu.waitMulti32(r,a),t[s]=r}};m.prototype.constructSTR1=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){var a=r[e]+i;t.mmu.store32(a,r[s]),t.mmu.wait(r[15]),t.mmu.wait32(a)}};m.prototype.constructSTR2=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){t.mmu.store32(r[e]+r[i],r[s]),t.mmu.wait(r[15]),t.mmu.wait32(r[e]+r[i])}};m.prototype.constructSTR3=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.store32(t[13]+e,t[s]),i.mmu.wait(t[15]),i.mmu.wait32(t[13]+e)}};m.prototype.constructSTRB1=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){var a=r[e]+i;t.mmu.store8(a,r[s]),t.mmu.wait(r[15]),t.mmu.wait(a)}};m.prototype.constructSTRB2=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){t.mmu.store8(r[e]+r[i],r[s]),t.mmu.wait(r[15]),t.mmu.wait(r[e]+r[i])}};m.prototype.constructSTRH1=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){var a=r[e]+i;t.mmu.store16(a,r[s]),t.mmu.wait(r[15]),t.mmu.wait(a)}};m.prototype.constructSTRH2=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){t.mmu.store16(r[e]+r[i],r[s]),t.mmu.wait(r[15]),t.mmu.wait(r[e]+r[i])}};m.prototype.constructSUB1=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){t.mmu.waitPrefetch(r[15]);var a=r[e]-i;t.cpsrN=a>>31,t.cpsrZ=!(a&4294967295),t.cpsrC=r[e]>>>0>=i,t.cpsrV=r[e]>>31&&(r[e]^a)>>31,r[s]=a}};m.prototype.constructSUB2=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]);var r=t[s]-e;i.cpsrN=r>>31,i.cpsrZ=!(r&4294967295),i.cpsrC=t[s]>>>0>=e,i.cpsrV=t[s]>>31&&(t[s]^r)>>31,t[s]=r}};m.prototype.constructSUB3=function(s,e,i){var t=this.cpu,r=t.gprs;return function(){t.mmu.waitPrefetch(r[15]);var a=r[e]-r[i];t.cpsrN=a>>31,t.cpsrZ=!(a&4294967295),t.cpsrC=r[e]>>>0>=r[i]>>>0,t.cpsrV=r[e]>>31!=r[i]>>31&&r[e]>>31!=a>>31,r[s]=a}};m.prototype.constructSWI=function(s){var e=this.cpu,i=e.gprs;return function(){e.irq.swi(s),e.mmu.waitPrefetch(i[15])}};m.prototype.constructTST=function(s,e){var i=this.cpu,t=i.gprs;return function(){i.mmu.waitPrefetch(t[15]);var r=t[s]&t[e];i.cpsrN=r>>31,i.cpsrZ=!(r&4294967295)}};function R(){this.SP=13,this.LR=14,this.PC=15,this.MODE_ARM=0,this.MODE_THUMB=1,this.MODE_USER=16,this.MODE_FIQ=17,this.MODE_IRQ=18,this.MODE_SUPERVISOR=19,this.MODE_ABORT=23,this.MODE_UNDEFINED=27,this.MODE_SYSTEM=31,this.BANK_NONE=0,this.BANK_FIQ=1,this.BANK_IRQ=2,this.BANK_SUPERVISOR=3,this.BANK_ABORT=4,this.BANK_UNDEFINED=5,this.WORD_SIZE_ARM=4,this.WORD_SIZE_THUMB=2,this.BASE_RESET=0,this.BASE_UNDEF=4,this.BASE_SWI=8,this.BASE_PABT=12,this.BASE_DABT=16,this.BASE_IRQ=24,this.BASE_FIQ=28,this.armCompiler=new F(this),this.thumbCompiler=new m(this),this.generateConds(),this.gprs=new Int32Array(16)}R.prototype.resetCPU=function(s){for(var e=0;e<15;++e)this.gprs[e]=0;this.gprs[15]=s+4,this.loadInstruction=this.loadInstructionArm,this.execMode=0,this.instructionWidth=4,this.mode=31,this.cpsrI=!1,this.cpsrF=!1,this.cpsrV=!1,this.cpsrC=!1,this.cpsrZ=!1,this.cpsrN=!1,this.bankedRegisters=[new Int32Array(7),new Int32Array(7),new Int32Array(2),new Int32Array(2),new Int32Array(2),new Int32Array(2)],this.spsr=0,this.bankedSPSRs=new Int32Array(6),this.cycles=0,this.shifterOperand=0,this.shifterCarryOut=0,this.page=null,this.pageId=0,this.pageRegion=-1,this.instruction=null,this.irq.clear();var i=this.gprs,t=this.mmu;this.step=function(){var r=this.instruction||(this.instruction=this.loadInstruction(i[15]-this.instructionWidth));if(i[15]+=this.instructionWidth,this.conditionPassed=!0,r(),!r.writesPC)this.instruction!=null&&((r.next==null||r.next.page.invalid)&&(r.next=this.loadInstruction(i[15]-this.instructionWidth)),this.instruction=r.next);else if(this.conditionPassed){var a=i[15]&=4294967294;this.execMode==0?(t.wait32(a),t.waitPrefetch32(a)):(t.wait(a),t.waitPrefetch(a)),i[15]+=this.instructionWidth,r.fixedJump?this.instruction!=null&&((r.next==null||r.next.page.invalid)&&(r.next=this.loadInstruction(i[15]-this.instructionWidth)),this.instruction=r.next):this.instruction=null}else this.instruction=null;this.irq.updateTimers()}};R.prototype.freeze=function(){return{PC:this.gprs[15]-this.instructionWidth,SP:this.gprs[13],gprs:[this.gprs[0],this.gprs[1],this.gprs[2],this.gprs[3],this.gprs[4],this.gprs[5],this.gprs[6],this.gprs[7],this.gprs[8],this.gprs[9],this.gprs[10],this.gprs[11],this.gprs[12],this.gprs[13],this.gprs[14],this.gprs[15]],mode:this.mode,cpsrI:this.cpsrI,cpsrF:this.cpsrF,cpsrV:this.cpsrV,cpsrC:this.cpsrC,cpsrZ:this.cpsrZ,cpsrN:this.cpsrN,bankedRegisters:[[this.bankedRegisters[0][0],this.bankedRegisters[0][1],this.bankedRegisters[0][2],this.bankedRegisters[0][3],this.bankedRegisters[0][4],this.bankedRegisters[0][5],this.bankedRegisters[0][6]],[this.bankedRegisters[1][0],this.bankedRegisters[1][1],this.bankedRegisters[1][2],this.bankedRegisters[1][3],this.bankedRegisters[1][4],this.bankedRegisters[1][5],this.bankedRegisters[1][6]],[this.bankedRegisters[2][0],this.bankedRegisters[2][1]],[this.bankedRegisters[3][0],this.bankedRegisters[3][1]],[this.bankedRegisters[4][0],this.bankedRegisters[4][1]],[this.bankedRegisters[5][0],this.bankedRegisters[5][1]]],spsr:this.spsr,bankedSPSRs:[this.bankedSPSRs[0],this.bankedSPSRs[1],this.bankedSPSRs[2],this.bankedSPSRs[3],this.bankedSPSRs[4],this.bankedSPSRs[5]],cycles:this.cycles,instructionWidth:this.instructionWidth}};R.prototype.defrost=function(s){this.instruction=null,this.page=null,this.pageId=0,this.pageRegion=-1,this.gprs[0]=s.gprs[0],this.gprs[1]=s.gprs[1],this.gprs[2]=s.gprs[2],this.gprs[3]=s.gprs[3],this.gprs[4]=s.gprs[4],this.gprs[5]=s.gprs[5],this.gprs[6]=s.gprs[6],this.gprs[7]=s.gprs[7],this.gprs[8]=s.gprs[8],this.gprs[9]=s.gprs[9],this.gprs[10]=s.gprs[10],this.gprs[11]=s.gprs[11],this.gprs[12]=s.gprs[12],this.gprs[13]=s.gprs[13],this.gprs[14]=s.gprs[14],this.gprs[15]=s.gprs[15],this.mode=s.mode,this.cpsrI=s.cpsrI,this.cpsrF=s.cpsrF,this.cpsrV=s.cpsrV,this.cpsrC=s.cpsrC,this.cpsrZ=s.cpsrZ,this.cpsrN=s.cpsrN,this.bankedRegisters[0][0]=s.bankedRegisters[0][0],this.bankedRegisters[0][1]=s.bankedRegisters[0][1],this.bankedRegisters[0][2]=s.bankedRegisters[0][2],this.bankedRegisters[0][3]=s.bankedRegisters[0][3],this.bankedRegisters[0][4]=s.bankedRegisters[0][4],this.bankedRegisters[0][5]=s.bankedRegisters[0][5],this.bankedRegisters[0][6]=s.bankedRegisters[0][6],this.bankedRegisters[1][0]=s.bankedRegisters[1][0],this.bankedRegisters[1][1]=s.bankedRegisters[1][1],this.bankedRegisters[1][2]=s.bankedRegisters[1][2],this.bankedRegisters[1][3]=s.bankedRegisters[1][3],this.bankedRegisters[1][4]=s.bankedRegisters[1][4],this.bankedRegisters[1][5]=s.bankedRegisters[1][5],this.bankedRegisters[1][6]=s.bankedRegisters[1][6],this.bankedRegisters[2][0]=s.bankedRegisters[2][0],this.bankedRegisters[2][1]=s.bankedRegisters[2][1],this.bankedRegisters[3][0]=s.bankedRegisters[3][0],this.bankedRegisters[3][1]=s.bankedRegisters[3][1],this.bankedRegisters[4][0]=s.bankedRegisters[4][0],this.bankedRegisters[4][1]=s.bankedRegisters[4][1],this.bankedRegisters[5][0]=s.bankedRegisters[5][0],this.bankedRegisters[5][1]=s.bankedRegisters[5][1],this.spsr=s.spsr,this.bankedSPSRs[0]=s.bankedSPSRs[0],this.bankedSPSRs[1]=s.bankedSPSRs[1],this.bankedSPSRs[2]=s.bankedSPSRs[2],this.bankedSPSRs[3]=s.bankedSPSRs[3],this.bankedSPSRs[4]=s.bankedSPSRs[4],this.bankedSPSRs[5]=s.bankedSPSRs[5],this.cycles=s.cycles,this.instructionWidth=s.instructionWidth,this.loadInstruction=s.instructionWidth==2?this.loadInstructionThumb:this.loadInstructionArm,this.execMode=s.instructionWidth==2?1:0};R.prototype.fetchPage=function(s){var e=this.mmu,i=s>>>e.BASE_OFFSET,t=e.addressToPage(i,s&e.OFFSET_MASK);if(i==this.pageRegion){if(t==this.pageId&&!this.page.invalid)return;this.pageId=t}else this.pageMask=e.memory[i].PAGE_MASK,this.pageRegion=i,this.pageId=t;this.page=e.accessPage(i,t)};R.prototype.loadInstructionArm=function(s){var e=null;this.fetchPage(s);var i=(s&this.pageMask)>>2;if(e=this.page.arm[i],e)return e;var t=this.mmu.load32(s)>>>0;return e=this.compileArm(t),e.next=null,e.page=this.page,e.address=s,e.opcode=t,this.page.arm[i]=e,e};R.prototype.loadInstructionThumb=function(s){var e=null;this.fetchPage(s);var i=(s&this.pageMask)>>1;if(e=this.page.thumb[i],e)return e;var t=this.mmu.load16(s);return e=this.compileThumb(t),e.next=null,e.page=this.page,e.address=s,e.opcode=t,this.page.thumb[i]=e,e};R.prototype.selectBank=function(s){switch(s){case 16:case 31:return 0;case 17:return 1;case 18:return 2;case 19:return 3;case 23:return 4;case 27:return 5;default:throw new y("Invalid user mode "+s+" passed to selectBank")}};R.prototype.switchExecMode=function(s){this.execMode!=s&&(this.execMode=s,s==0?(this.instructionWidth=4,this.loadInstruction=this.loadInstructionArm):(this.instructionWidth=2,this.loadInstruction=this.loadInstructionThumb))};R.prototype.switchMode=function(s){if(s!=this.mode){if(s!=16||s!=31){var e=this.selectBank(s),i=this.selectBank(this.mode);if(e!=i){if(s==17||this.mode==17){var t=i==1?1:0,r=e==1?1:0;this.bankedRegisters[t][2]=this.gprs[8],this.bankedRegisters[t][3]=this.gprs[9],this.bankedRegisters[t][4]=this.gprs[10],this.bankedRegisters[t][5]=this.gprs[11],this.bankedRegisters[t][6]=this.gprs[12],this.gprs[8]=this.bankedRegisters[r][2],this.gprs[9]=this.bankedRegisters[r][3],this.gprs[10]=this.bankedRegisters[r][4],this.gprs[11]=this.bankedRegisters[r][5],this.gprs[12]=this.bankedRegisters[r][6]}this.bankedRegisters[i][0]=this.gprs[13],this.bankedRegisters[i][1]=this.gprs[14],this.gprs[13]=this.bankedRegisters[e][0],this.gprs[14]=this.bankedRegisters[e][1],this.bankedSPSRs[i]=this.spsr,this.spsr=this.bankedSPSRs[e]}}this.mode=s}};R.prototype.packCPSR=function(){return this.mode|this.execMode<<5|this.cpsrF<<6|this.cpsrI<<7|this.cpsrN<<31|this.cpsrZ<<30|this.cpsrC<<29|this.cpsrV<<28};R.prototype.unpackCPSR=function(s){this.switchMode(s&31),this.switchExecMode(!!(s&32)),this.cpsrF=s&64,this.cpsrI=s&128,this.cpsrN=s&2147483648,this.cpsrZ=s&1073741824,this.cpsrC=s&536870912,this.cpsrV=s&268435456,this.irq.testIRQ()};R.prototype.hasSPSR=function(){return this.mode!=31&&this.mode!=16};R.prototype.raiseIRQ=function(){if(!this.cpsrI){var s=this.packCPSR(),e=this.instructionWidth;this.switchMode(18),this.spsr=s,this.gprs[14]=this.gprs[15]-e+4,this.gprs[15]=this.BASE_IRQ+4,this.instruction=null,this.switchExecMode(0),this.cpsrI=!0}};R.prototype.raiseTrap=function(){var s=this.packCPSR(),e=this.instructionWidth;this.switchMode(19),this.spsr=s,this.gprs[14]=this.gprs[15]-e,this.gprs[15]=this.BASE_SWI+4,this.instruction=null,this.switchExecMode(0),this.cpsrI=!0};R.prototype.badOp=function(s){var e=function(){throw new y("Illegal instruction: 0x"+s.toString(16))};return e.writesPC=!0,e.fixedJump=!1,e};R.prototype.generateConds=function(){var s=this;this.conds=[function(){return s.conditionPassed=s.cpsrZ},function(){return s.conditionPassed=!s.cpsrZ},function(){return s.conditionPassed=s.cpsrC},function(){return s.conditionPassed=!s.cpsrC},function(){return s.conditionPassed=s.cpsrN},function(){return s.conditionPassed=!s.cpsrN},function(){return s.conditionPassed=s.cpsrV},function(){return s.conditionPassed=!s.cpsrV},function(){return s.conditionPassed=s.cpsrC&&!s.cpsrZ},function(){return s.conditionPassed=!s.cpsrC||s.cpsrZ},function(){return s.conditionPassed=!s.cpsrN==!s.cpsrV},function(){return s.conditionPassed=!s.cpsrN!=!s.cpsrV},function(){return s.conditionPassed=!s.cpsrZ&&!s.cpsrN==!s.cpsrV},function(){return s.conditionPassed=s.cpsrZ||!s.cpsrN!=!s.cpsrV},null,null]};R.prototype.barrelShiftImmediate=function(s,e,i){var t=this,r=this.gprs,a=this.badOp;switch(s){case 0:e?a=function(){t.shifterOperand=r[i]<>>e,t.shifterCarryOut=r[i]&1<>e,t.shifterCarryOut=r[i]&1<>>e|r[i]<<32-e,t.shifterCarryOut=r[i]&1<>>1,t.shifterCarryOut=r[i]&1};break}return a};R.prototype.compileArm=function(s){var e=this.badOp(s),i=s&234881024,t=this,r=this.gprs,a=this.conds[(s&4026531840)>>>28];if((s&268435440)==19922704){var c=s&15;e=this.armCompiler.constructBX(c,a),e.writesPC=!0,e.fixedJump=!1}else if(!(s&201326592)&&(i==33554432||(s&144)!=144)){var p=s&31457280,n=s&1048576,o=!1;if((p&25165824)==16777216&&!n){var v=s&4194304;if((s&11595776)==2158592){var c=s&15,x=s&255,w=(s&3840)>>7;x=x>>>w|x<<32-w,e=this.armCompiler.constructMSR(c,v,s,x,a),e.writesPC=!1}else if((s&12517376)==983040){var h=(s&61440)>>12;e=this.armCompiler.constructMRS(h,v,a),e.writesPC=h==15}}else{var f=(s&983040)>>16,h=(s&61440)>>12,l=s&96,c=s&15,C=function(){throw new y("BUG: invalid barrel shifter")};if(s&33554432){var x=s&255,V=(s&3840)>>7;V?C=this.armCompiler.constructAddressingMode1ImmediateRotate(x,V):C=this.armCompiler.constructAddressingMode1Immediate(x)}else if(s&16){var P=(s&3840)>>8;switch(o=!0,l){case 0:C=this.armCompiler.constructAddressingMode1LSL(P,c);break;case 32:C=this.armCompiler.constructAddressingMode1LSR(P,c);break;case 64:C=this.armCompiler.constructAddressingMode1ASR(P,c);break;case 96:C=this.armCompiler.constructAddressingMode1ROR(P,c);break}}else{var x=(s&3968)>>7;C=this.barrelShiftImmediate(l,x,c)}switch(p){case 0:n?e=this.armCompiler.constructANDS(h,f,C,a):e=this.armCompiler.constructAND(h,f,C,a);break;case 2097152:n?e=this.armCompiler.constructEORS(h,f,C,a):e=this.armCompiler.constructEOR(h,f,C,a);break;case 4194304:n?e=this.armCompiler.constructSUBS(h,f,C,a):e=this.armCompiler.constructSUB(h,f,C,a);break;case 6291456:n?e=this.armCompiler.constructRSBS(h,f,C,a):e=this.armCompiler.constructRSB(h,f,C,a);break;case 8388608:n?e=this.armCompiler.constructADDS(h,f,C,a):e=this.armCompiler.constructADD(h,f,C,a);break;case 10485760:n?e=this.armCompiler.constructADCS(h,f,C,a):e=this.armCompiler.constructADC(h,f,C,a);break;case 12582912:n?e=this.armCompiler.constructSBCS(h,f,C,a):e=this.armCompiler.constructSBC(h,f,C,a);break;case 14680064:n?e=this.armCompiler.constructRSCS(h,f,C,a):e=this.armCompiler.constructRSC(h,f,C,a);break;case 16777216:e=this.armCompiler.constructTST(h,f,C,a);break;case 18874368:e=this.armCompiler.constructTEQ(h,f,C,a);break;case 20971520:e=this.armCompiler.constructCMP(h,f,C,a);break;case 23068672:e=this.armCompiler.constructCMN(h,f,C,a);break;case 25165824:n?e=this.armCompiler.constructORRS(h,f,C,a):e=this.armCompiler.constructORR(h,f,C,a);break;case 27262976:n?e=this.armCompiler.constructMOVS(h,f,C,a):e=this.armCompiler.constructMOV(h,f,C,a);break;case 29360128:n?e=this.armCompiler.constructBICS(h,f,C,a):e=this.armCompiler.constructBIC(h,f,C,a);break;case 31457280:n?e=this.armCompiler.constructMVNS(h,f,C,a):e=this.armCompiler.constructMVN(h,f,C,a);break}e.writesPC=h==15}}else if((s&263196656)==16777360){var c=s&15,h=s>>12&15,f=s>>16&15;s&4194304?e=this.armCompiler.constructSWPB(h,f,c,a):e=this.armCompiler.constructSWP(h,f,c,a),e.writesPC=h==15}else switch(i){case 0:if((s&16777456)==144){var h=(s&983040)>>16,f=(s&61440)>>12,P=(s&3840)>>8,c=s&15;switch(s&15728640){case 0:e=this.armCompiler.constructMUL(h,P,c,a);break;case 1048576:e=this.armCompiler.constructMULS(h,P,c,a);break;case 2097152:e=this.armCompiler.constructMLA(h,f,P,c,a);break;case 3145728:e=this.armCompiler.constructMLAS(h,f,P,c,a);break;case 8388608:e=this.armCompiler.constructUMULL(h,f,P,c,a);break;case 9437184:e=this.armCompiler.constructUMULLS(h,f,P,c,a);break;case 10485760:e=this.armCompiler.constructUMLAL(h,f,P,c,a);break;case 11534336:e=this.armCompiler.constructUMLALS(h,f,P,c,a);break;case 12582912:e=this.armCompiler.constructSMULL(h,f,P,c,a);break;case 13631488:e=this.armCompiler.constructSMULLS(h,f,P,c,a);break;case 14680064:e=this.armCompiler.constructSMLAL(h,f,P,c,a);break;case 15728640:e=this.armCompiler.constructSMLALS(h,f,P,c,a);break}e.writesPC=h==15}else{var T=s&1048576,h=(s&61440)>>12,cr=(s&3840)>>4,ur=c=s&15,H=s&32,n=s&64,k=s&2097152,i=s&4194304,d;if(i){var x=ur|cr;d=this.armCompiler.constructAddressingMode23Immediate(s,x,a)}else d=this.armCompiler.constructAddressingMode23Register(s,c,a);d.writesPC=!!k&&f==15,(s&144)==144&&(T?H?n?e=this.armCompiler.constructLDRSH(h,d,a):e=this.armCompiler.constructLDRH(h,d,a):n&&(e=this.armCompiler.constructLDRSB(h,d,a)):!n&&H&&(e=this.armCompiler.constructSTRH(h,d,a))),e.writesPC=h==15||d.writesPC}break;case 67108864:case 100663296:var h=(s&61440)>>12,T=s&1048576,W=s&4194304,i=s&33554432,d=function(){throw new y("Unimplemented memory access: 0x"+s.toString(16))};if(~s&16777216&&(s&=4292870143),i){var c=s&15,l=s&96,K=(s&3968)>>7;l||K?(C=this.barrelShiftImmediate(l,K,c),d=this.armCompiler.constructAddressingMode2RegisterShifted(s,C,a)):d=this.armCompiler.constructAddressingMode23Register(s,c,a)}else{var M=s&4095;d=this.armCompiler.constructAddressingMode23Immediate(s,M,a)}T?W?e=this.armCompiler.constructLDRB(h,d,a):e=this.armCompiler.constructLDR(h,d,a):W?e=this.armCompiler.constructSTRB(h,d,a):e=this.armCompiler.constructSTR(h,d,a),e.writesPC=T&&(h==15||d.writesPC);break;case 134217728:var T=s&1048576,k=s&2097152,Q=s&4194304,pr=s&8388608,G=s&16777216,P=s&65535,f=(s&983040)>>16,d,x=0,M=0,B=!1;if(pr){G&&(x=4);for(var A=1,i=0;i<16;A<<=1,++i)P&A&&(k&&i==f&&!M&&(P&=~A,x+=4,B=!0),M+=4)}else{G||(x=4);for(var A=1,i=0;i<16;A<<=1,++i)P&A&&(k&&i==f&&!M&&(P&=~A,x+=4,B=!0),x-=4,M-=4)}k?d=this.armCompiler.constructAddressingMode4Writeback(x,M,f,B):d=this.armCompiler.constructAddressingMode4(x,f),T?(Q?e=this.armCompiler.constructLDMS(P,d,a):e=this.armCompiler.constructLDM(P,d,a),e.writesPC=!!(P&1<<15)):(Q?e=this.armCompiler.constructSTMS(P,d,a):e=this.armCompiler.constructSTM(P,d,a),e.writesPC=!1);break;case 167772160:var x=s&16777215;x&8388608&&(x|=4278190080),x<<=2;var nr=s&16777216;nr?e=this.armCompiler.constructBL(x,a):e=this.armCompiler.constructB(x,a),e.writesPC=!0,e.fixedJump=!0;break;case 201326592:break;case 234881024:if((s&251658240)==251658240){var x=s&16777215;e=this.armCompiler.constructSWI(x,a),e.writesPC=!1}break;default:throw new y("Bad opcode: 0x"+s.toString(16))}return e.execMode=0,e.fixedJump=e.fixedJump||!1,e};R.prototype.compileThumb=function(s){var e=this.badOp(s&65535),i=this,t=this.gprs;if((s&64512)==16384){var r=(s&56)>>3,a=s&7;switch(s&960){case 0:e=this.thumbCompiler.constructAND(a,r);break;case 64:e=this.thumbCompiler.constructEOR(a,r);break;case 128:e=this.thumbCompiler.constructLSL2(a,r);break;case 192:e=this.thumbCompiler.constructLSR2(a,r);break;case 256:e=this.thumbCompiler.constructASR2(a,r);break;case 320:e=this.thumbCompiler.constructADC(a,r);break;case 384:e=this.thumbCompiler.constructSBC(a,r);break;case 448:e=this.thumbCompiler.constructROR(a,r);break;case 512:e=this.thumbCompiler.constructTST(a,r);break;case 576:e=this.thumbCompiler.constructNEG(a,r);break;case 640:e=this.thumbCompiler.constructCMP2(a,r);break;case 704:e=this.thumbCompiler.constructCMN(a,r);break;case 768:e=this.thumbCompiler.constructORR(a,r);break;case 832:e=this.thumbCompiler.constructMUL(a,r);break;case 896:e=this.thumbCompiler.constructBIC(a,r);break;case 960:e=this.thumbCompiler.constructMVN(a,r);break}e.writesPC=!1}else if((s&64512)==17408){var r=(s&120)>>3,c=s&7,p=s&128,a=c|p>>4;switch(s&768){case 0:e=this.thumbCompiler.constructADD4(a,r),e.writesPC=a==15;break;case 256:e=this.thumbCompiler.constructCMP3(a,r),e.writesPC=!1;break;case 512:e=this.thumbCompiler.constructMOV3(a,r),e.writesPC=a==15;break;case 768:e=this.thumbCompiler.constructBX(a,r),e.writesPC=!0,e.fixedJump=!1;break}}else if((s&63488)==6144){var r=(s&448)>>6,c=(s&56)>>3,a=s&7;switch(s&1536){case 0:e=this.thumbCompiler.constructADD3(a,c,r);break;case 512:e=this.thumbCompiler.constructSUB3(a,c,r);break;case 1024:var n=(s&448)>>6;n?e=this.thumbCompiler.constructADD1(a,c,n):e=this.thumbCompiler.constructMOV2(a,c,r);break;case 1536:var n=(s&448)>>6;e=this.thumbCompiler.constructSUB1(a,c,n);break}e.writesPC=!1}else if(s&57344)if((s&57344)==8192){var n=s&255,c=(s&1792)>>8;switch(s&6144){case 0:e=this.thumbCompiler.constructMOV1(c,n);break;case 2048:e=this.thumbCompiler.constructCMP1(c,n);break;case 4096:e=this.thumbCompiler.constructADD2(c,n);break;case 6144:e=this.thumbCompiler.constructSUB2(c,n);break}e.writesPC=!1}else if((s&63488)==18432){var a=(s&1792)>>8,n=(s&255)<<2;e=this.thumbCompiler.constructLDR3(a,n),e.writesPC=!1}else if((s&61440)==20480){var a=s&7,c=(s&56)>>3,r=(s&448)>>6,o=s&3584;switch(o){case 0:e=this.thumbCompiler.constructSTR2(a,c,r);break;case 512:e=this.thumbCompiler.constructSTRH2(a,c,r);break;case 1024:e=this.thumbCompiler.constructSTRB2(a,c,r);break;case 1536:e=this.thumbCompiler.constructLDRSB(a,c,r);break;case 2048:e=this.thumbCompiler.constructLDR2(a,c,r);break;case 2560:e=this.thumbCompiler.constructLDRH2(a,c,r);break;case 3072:e=this.thumbCompiler.constructLDRB2(a,c,r);break;case 3584:e=this.thumbCompiler.constructLDRSH(a,c,r);break}e.writesPC=!1}else if((s&57344)==24576){var a=s&7,c=(s&56)>>3,n=(s&1984)>>4,v=s&4096;v&&(n>>=2);var x=s&2048;x?v?e=this.thumbCompiler.constructLDRB1(a,c,n):e=this.thumbCompiler.constructLDR1(a,c,n):v?e=this.thumbCompiler.constructSTRB1(a,c,n):e=this.thumbCompiler.constructSTR1(a,c,n),e.writesPC=!1}else if((s&62976)==46080){var w=!!(s&256),h=s&255;s&2048?(e=this.thumbCompiler.constructPOP(h,w),e.writesPC=w,e.fixedJump=!1):(e=this.thumbCompiler.constructPUSH(h,w),e.writesPC=!1)}else if(s&32768)switch(s&28672){case 0:var a=s&7,c=(s&56)>>3,n=(s&1984)>>5;s&2048?e=this.thumbCompiler.constructLDRH1(a,c,n):e=this.thumbCompiler.constructSTRH1(a,c,n),e.writesPC=!1;break;case 4096:var a=(s&1792)>>8,n=(s&255)<<2,x=s&2048;x?e=this.thumbCompiler.constructLDR4(a,n):e=this.thumbCompiler.constructSTR3(a,n),e.writesPC=!1;break;case 8192:var a=(s&1792)>>8,n=(s&255)<<2;s&2048?e=this.thumbCompiler.constructADD6(a,n):e=this.thumbCompiler.constructADD5(a,n),e.writesPC=!1;break;case 12288:if(!(s&3840)){var v=s&128,n=(s&127)<<2;v&&(n=-n),e=this.thumbCompiler.constructADD7(n),e.writesPC=!1}break;case 16384:var c=(s&1792)>>8,h=s&255;s&2048?e=this.thumbCompiler.constructLDMIA(c,h):e=this.thumbCompiler.constructSTMIA(c,h),e.writesPC=!1;break;case 20480:var f=(s&3840)>>8,n=s&255;if(f==15)e=this.thumbCompiler.constructSWI(n),e.writesPC=!1;else{s&128&&(n|=4294967040),n<<=1;var l=this.conds[f];e=this.thumbCompiler.constructB1(n,l),e.writesPC=!0,e.fixedJump=!0}break;case 24576:case 28672:var n=s&2047,C=s&6144;switch(C){case 0:n&1024&&(n|=4294965248),n<<=1,e=this.thumbCompiler.constructB2(n),e.writesPC=!0,e.fixedJump=!0;break;case 2048:break;case 4096:n&1024&&(n|=4294966272),n<<=12,e=this.thumbCompiler.constructBL1(n),e.writesPC=!1;break;case 6144:e=this.thumbCompiler.constructBL2(n),e.writesPC=!0,e.fixedJump=!1;break}break;default:throw new y("Undefined instruction: 0x"+s.toString(16))}else throw new y("Bad opcode: 0x"+s.toString(16));else{var a=s&7,r=(s&56)>>3,n=(s&1984)>>6;switch(s&6144){case 0:e=this.thumbCompiler.constructLSL1(a,r,n);break;case 2048:e=this.thumbCompiler.constructLSR1(a,r,n);break;case 4096:e=this.thumbCompiler.constructASR1(a,r,n);break;case 6144:break}e.writesPC=!1}return e.execMode=1,e.fixedJump=e.fixedJump||!1,e};var U=class{constructor(){this.BASE_OFFSET=24;this.OFFSET_MASK=16777215;this.core=new R,this.core.irq=this,this.core.mmu=this,this.resetMemory()}resetMemory(){this.memory=[];for(var e=0;e<256;e++){var i=10,t=524288;this.memory[e]={PAGE_MASK:(2<0?e:1}getPC(){return this.core.gprs[15]-this.core.instructionWidth}getSP(){return this.core.gprs[13]}isStable(){return!0}connectMemoryBus(e){this.bus=e}reset(){this.resetMemory(),this.core.resetCPU(0)}saveState(){return this.core.freeze()}loadState(e){this.core.defrost(e)}load8(e){return this.bus.read(e)<<24>>24}loadU8(e){return this.bus.read(e)&255}load16(e){return this.loadU16(e)<<16>>16}loadU16(e){return this.bus.read(e)|this.bus.read(e+1)<<8}load32(e){var i=this.bus.read(e)|this.bus.read(e+1)<<8|this.bus.read(e+2)<<16|this.bus.read(e+3)<<24;return i}store8(e,i){this.bus.write(e,i&255)}store16(e,i){this.bus.write(e,i&255),this.bus.write(e+1,i>>8&255)}store32(e,i){this.bus.write(e,i&255),this.bus.write(e+1,i>>8&255),this.bus.write(e+2,i>>16&255),this.bus.write(e+3,i>>24&255)}wait(e){++this.core.cycles}wait32(e){++this.core.cycles}waitSeq32(e){++this.core.cycles}waitMul(e){(e&4294967040)==4294967040||!(e&4294967040)?this.core.cycles+=1:(e&4294901760)==4294901760||!(e&4294901760)?this.core.cycles+=2:(e&4278190080)==4278190080||!(e&4278190080)?this.core.cycles+=3:this.core.cycles+=4}waitMulti32(e,i){this.core.cycles+=2}waitPrefetch(e){++this.core.cycles}waitPrefetch32(e){++this.core.cycles}addressToPage(e,i){return i>>this.memory[e].ICACHE_PAGE_BITS}accessPage(e,i){var t=this.memory[e],r=t.icache[i];return(!r||r.invalid)&&(r={thumb:new Array(1<>16)}clear(){}updateTimers(){}testIRQ(){}isThumb(){return this.core.instructionWidth==2}};var Fr=X([[S.A,0,1],[S.B,0,2],[S.GP_A,0,1],[S.GP_B,0,2],[S.SELECT,0,4],[S.START,0,8],[S.RIGHT,0,16],[S.LEFT,0,32],[S.UP,0,64],[S.DOWN,0,128]]),er=0,tr=524288,I=33554432,D=524288,O=67108864,_=256,hr=1e6,sr=4e6,Z=class extends q{constructor(){super();this.cpuFrequency=sr;this.canvasWidth=160;this.numTotalScanlines=256;this.numVisibleScanlines=128;this.cpuCyclesPerLine=Math.floor(sr/(256*60));this.defaultROMSize=512*1024;this.sampleRate=1;this.cpu=new U;this.ram=new Uint8Array(96*1024);this.ram16=new Uint16Array(this.ram.buffer);this.vidbase=0;this.brightness=255;this.read=L([[er,er+tr-1,tr-1,e=>this.rom?this.rom[e]:0],[I,I+D-1,D-1,e=>this.ram[e]],[O,O+_-1,_-1,(e,i)=>this.readIO(e)],[0,(1<<31)-1,0,(e,i)=>{throw new y(`Address read out of bounds: 0x${E(e)}`)}]]);this.write=L([[I,I+D-1,D-1,(e,i)=>{this.ram[e]=i}],[O,O+_-1,_-1,(e,i)=>{this.writeIO(e,i)}]]);this.connectCPUMemoryBus(this),this.handler=z(this.inputs,Fr)}connectVideo(e){super.connectVideo(e),this.pixels32=e,this.pixels8=new Uint8Array(e.buffer)}connectSerialIO(e){this.serial=e}reset(){super.reset(),this.serialOut=[],this.serialIn=[]}readIO(e){switch(e){case 0:return this.inputs[0];case 64:return(this.serial.byteAvailable()?128:0)|(this.serial.clearToSend()?64:0);case 68:let i=this.serialIn.shift();return i!=null?(this.serialOut.push(i),i.value):0;default:return 0}}writeIO(e,i){switch(e){case 0:break;case 72:this.serialOut.length>1&1048575,t=this.brightness<<24,r=0;r>5&31)<<11|(a>>10&31)<<19}}getDebugCategories(){return["CPU","Stack"]}getDebugInfo(e,i){switch(e){case"CPU":var t="",r=i.c;let c={2:"Thumb",4:"ARM"},p={15:"PC",14:"LR",13:"SP",12:"IP",11:"FP",9:"SB"};for(var a=0;a<16;a++)t+=N(p[a]||"",3)+N("r"+a,5)+" "+E(r.gprs[a],8)+` `;return t+="Flags ",t+=r.cpsrN?" N":" -",t+=r.cpsrV?" V":" -",t+=r.cpsrF?" F":" -",t+=r.cpsrZ?" Z":" -",t+=r.cpsrC?" C":" -",t+=r.cpsrI?" I":" -",t+=` `,t+="MODE "+c[r.instructionWidth]+" "+mr[r.mode]+` `,t+="SPSR "+E(r.spsr,8)+` `,t+="cycl "+r.cycles+` `,t}}saveState(){var e=super.saveState();return e.serial={sin:this.serialIn.slice(0),sout:this.serialOut.slice(0)},e}loadState(e){super.loadState(e),this.serialIn=e.serial.sin,this.serialOut=e.serial.sout}},mr={16:"USER",17:"FIQ",18:"IRQ",19:"SUPERVISOR",23:"ABORT",27:"UNDEFINED",31:"SYSTEM"};var fr=[{id:"vidfill.vasm",name:"Video Memory Fill"}];var Wr=512*1024;var Kr=512*1024;var ir=class extends j{getToolForFilename(e){return e.endsWith(".vasm")?"vasmarm":e.endsWith(".armips")?"armips":"vasmarm"}getPresets(){return fr}getDefaultExtension(){return".vasm"}},ar=class extends ir{constructor(){super(...arguments);this.getMemoryMap=function(){return{main:[{name:"ROM",start:0,size:524288,type:"rom"},{name:"RAM",start:33554432,size:524288,type:"ram"},{name:"I/O",start:67108864,size:256,type:"io"}]}}}async start(){super.start(),console.log("Loading Capstone"),await J("./lib/capstone-arm.min.js"),this.capstone_arm=new cs.Capstone(cs.ARCH_ARM,cs.MODE_ARM),this.capstone_thumb=new cs.Capstone(cs.ARCH_ARM,cs.MODE_THUMB)}newMachine(){return new Z}readAddress(e){return this.machine.read(e)}disassemble(e,i){for(var t=this.machine.cpu.isThumb(),r=t?this.capstone_thumb:this.capstone_arm,a=[],c=0;c<4;c++)a[c]=i(e+c);var p=r.disasm(a,e,4),n=p&&p[0];return n?{nbytes:n.size,line:n.mnemonic+" "+n.op_str,isaddr:n.address>0}:{nbytes:4,line:"???",isaddr:!1}}};Y.arm32=ar;export{ir as BaseARMMachinePlatform}; -//# sourceMappingURL=arm32-ZZE4VEXM.js.map +//# sourceMappingURL=arm32-TREQBG5P.js.map diff --git a/gen/arm32-ZZE4VEXM.js.map b/gen/arm32-TREQBG5P.js.map similarity index 100% rename from gen/arm32-ZZE4VEXM.js.map rename to gen/arm32-TREQBG5P.js.map diff --git a/gen/astrocade-VLTUF6PT.js b/gen/astrocade-HTRRXIK3.js similarity index 98% rename from gen/astrocade-VLTUF6PT.js rename to gen/astrocade-HTRRXIK3.js index a78868e5..95f57d52 100644 --- a/gen/astrocade-VLTUF6PT.js +++ b/gen/astrocade-HTRRXIK3.js @@ -1,4 +1,4 @@ -import{J as d0,c as t0,d as r0,e as i0,k as s0,q as n0}from"./chunk-4UNLDFGJ.js";import{$ as S,J as y,V as A,W as F0,Y as A0,_ as Z,g as o,k as $,l as x0,s as e0}from"./chunk-47V4PEOO.js";import"./chunk-5XVCUSSZ.js";var C0=A0([[A.UP,16,1],[A.DOWN,16,2],[A.LEFT,16,4],[A.RIGHT,16,8],[A.A,16,16],[A.P2_UP,17,1],[A.P2_DOWN,17,2],[A.P2_LEFT,17,4],[A.P2_RIGHT,17,8],[A.P2_A,17,16],[A.VK_P,20,1],[A.VK_SLASH,20,2],[A.VK_X,20,4],[A.VK_MINUS,20,8],[A.VK_COMMA,20,16],[A.VK_EQUALS,20,32],[A.VK_O,21,1],[A.VK_L,21,2],[A.VK_9,21,4],[A.VK_6,21,8],[A.VK_3,21,16],[A.VK_PERIOD,21,32],[A.VK_I,22,1],[A.VK_K,22,2],[A.VK_8,22,4],[A.VK_5,22,8],[A.VK_2,22,16],[A.VK_0,22,32],[A.VK_U,23,1],[A.VK_J,23,2],[A.VK_7,23,4],[A.VK_4,23,8],[A.VK_1,23,16],[A.VK_BACK_SLASH,23,32]]),a0=2,m0=function(d){var F,r,B,C,b,O,L,U;let V=d?320:160,N=d?204:102,z=V>>2,h0=256,u0=4293848814,Y0=4278190080;var I=new Uint8Array(32),a=0,m=0,c=!1,l=0,D=0,E=0,Q=0,h=0,u=N,P=new Uint32Array(8),G=new Uint8Array(8),k=0,K=new Uint8Array(d?262:131),b0=!1,g=new Uint8Array(4),X=0,Y=0,j=0;function R(x,e){r[x]=e,j++,K[(x&4095)/z|0]=1}function g0(x,e){for(var s=x*4+3,f=0;f<4;f++){var w=x%z>=(D&63)?0:4;L[s--]=P[w+(e&3)],e>>=2}}function _(x){for(var e=x*V/4,s=0;s>=4);for(var f=0;f<4;f++){var w=e&1?m>>2&3:m&3;s|=w<>=1}e=s,c=!c}if(a&4){if(X&4){var n=2*(~X&3);e=(g[3]>>n&3)<<6|(g[2]>>n&3)<<4|(g[1]>>n&3)<<2|(g[0]>>n&3)<<0}else g[X&3]=e;X++}else{var n=(a&3)<<1,s=e>>n|l;l=e<<8-n&255,e=s}if(a&64&&(e=(e&3)<<6|(e&12)<<2|(e&48)>>2|(e&192)>>6),a&48){var t=r[x],i=0;t&192&&e&192&&(i|=1),t&48&&e&48&&(i|=2),t&12&&e&12&&(i|=4),t&3&&e&3&&(i|=8),a&16&&(e|=t),a&32&&(e^=t),Y=Y&240|i|i<<4}R(x,e)}function W(x,e){G[x&7]=e&255,P[x&7]=J[e&255],H()}function X0(){var x=D>>6}function H(){k=N}this.drawScanline=x=>{x==Q&&E&8&&(F.retryInterrupts=!(E&4),this.probe&&this.probe.logInterrupt(h),F.interrupt(h)),x0?(K[x]=0,_(x),k--):K[x]&&(K[x]=0,_(x))},this.init=(x,e,s,f,w)=>{F=e,r=s,I=f,U=w,O=Z(new $().decode(x0(atob(l0))),8192),d?B={read:S([[16384,32767,16383,function(t){return r[t]}],[53248,57343,4095,function(t){return r[t+16384]}],[0,45055,65535,function(t){return b?b[t]:0}]]),write:S([[16384,32767,16383,R],[53248,57343,4095,function(t,i){R(t+16384,i)}],[0,16383,16383,q]])}:B={read:S([[0,8191,8191,function(t){return O[t]}],[8192,16383,8191,function(t){return b?b[t]:0}],[16384,20479,4095,function(t){return j++,r[t]}]]),write:S([[16384,20479,4095,R],[0,16383,4095,q]])},C={read:function(t){t&=31;var i;switch(t){case 8:i=Y,Y=0;break;default:i=I[t];break}return i},write:function(t,i){switch(t&=31,i&=255,t){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:W(t,i);break;case 9:D=i,X0(),H();break;case 10:u=d?i:i>>1,H();break;case 11:var p=F.saveState();W((p.BC>>8)-1,B.read(p.HL));break;case 12:a=i,l=0,X=0,c=!1;break;case 13:h=i;break;case 14:E=i;break;case 15:Q=d?i:i>>1;break;case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:U.setACRegister(t,i);break;case 24:var p=F.saveState();U.setACRegister((p.BC>>8)-1,B.read(p.HL));break;case 25:m=i;break;default:console.log("IO write",o(t,4),o(i,2));break}}},x.connectCPUMemoryBus(B),x.connectCPUIOBus(C),this.membus=B,this.iobus=C;for(var n=0;n<8;n++)W(n,n)},this.resetWaitStates=function(x){var e=x{F.loadState(x.c),r.set(x.ram),P.set(x.palette),G.set(x.palinds),a=x.magicop,m=x.xpand,c=x.xplower,l=x.shift2,D=x.horcb,E=x.inmod,Q=x.inlin,h=x.infbk,u=x.verbl,X=x.rotcount,g.set(x.rotdata),Y=x.intst,I.set(x.inputs),H()},this.saveState=()=>({c:F.saveState(),ram:r.slice(0),inputs:I.slice(0),palette:P.slice(0),palinds:G.slice(0),magicop:a,xpand:m,xplower:c,shift2:l,horcb:D,inmod:E,inlin:Q,infbk:h,verbl:u,rotcount:X,rotdata:g.slice(0),intst:Y}),this.reset=()=>{a=m=E=Q=h=l=D=0,u=N,c=!1},this.toLongString=x=>{var e="";e+=` +import{J as d0,c as t0,d as r0,e as i0,k as s0,q as n0}from"./chunk-GKVIY6GD.js";import{H as y,T as A,U as F0,W as A0,Y as Z,Z as S,g as o,k as $,l as x0,s as e0}from"./chunk-YL2YTMD7.js";import"./chunk-RQFURXHW.js";var C0=A0([[A.UP,16,1],[A.DOWN,16,2],[A.LEFT,16,4],[A.RIGHT,16,8],[A.A,16,16],[A.P2_UP,17,1],[A.P2_DOWN,17,2],[A.P2_LEFT,17,4],[A.P2_RIGHT,17,8],[A.P2_A,17,16],[A.VK_P,20,1],[A.VK_SLASH,20,2],[A.VK_X,20,4],[A.VK_MINUS,20,8],[A.VK_COMMA,20,16],[A.VK_EQUALS,20,32],[A.VK_O,21,1],[A.VK_L,21,2],[A.VK_9,21,4],[A.VK_6,21,8],[A.VK_3,21,16],[A.VK_PERIOD,21,32],[A.VK_I,22,1],[A.VK_K,22,2],[A.VK_8,22,4],[A.VK_5,22,8],[A.VK_2,22,16],[A.VK_0,22,32],[A.VK_U,23,1],[A.VK_J,23,2],[A.VK_7,23,4],[A.VK_4,23,8],[A.VK_1,23,16],[A.VK_BACK_SLASH,23,32]]),a0=2,m0=function(d){var F,r,B,C,b,O,L,U;let V=d?320:160,N=d?204:102,z=V>>2,h0=256,u0=4293848814,Y0=4278190080;var I=new Uint8Array(32),a=0,m=0,c=!1,l=0,D=0,E=0,Q=0,h=0,u=N,P=new Uint32Array(8),G=new Uint8Array(8),k=0,K=new Uint8Array(d?262:131),b0=!1,g=new Uint8Array(4),X=0,Y=0,j=0;function R(x,e){r[x]=e,j++,K[(x&4095)/z|0]=1}function g0(x,e){for(var s=x*4+3,f=0;f<4;f++){var w=x%z>=(D&63)?0:4;L[s--]=P[w+(e&3)],e>>=2}}function _(x){for(var e=x*V/4,s=0;s>=4);for(var f=0;f<4;f++){var w=e&1?m>>2&3:m&3;s|=w<>=1}e=s,c=!c}if(a&4){if(X&4){var n=2*(~X&3);e=(g[3]>>n&3)<<6|(g[2]>>n&3)<<4|(g[1]>>n&3)<<2|(g[0]>>n&3)<<0}else g[X&3]=e;X++}else{var n=(a&3)<<1,s=e>>n|l;l=e<<8-n&255,e=s}if(a&64&&(e=(e&3)<<6|(e&12)<<2|(e&48)>>2|(e&192)>>6),a&48){var t=r[x],i=0;t&192&&e&192&&(i|=1),t&48&&e&48&&(i|=2),t&12&&e&12&&(i|=4),t&3&&e&3&&(i|=8),a&16&&(e|=t),a&32&&(e^=t),Y=Y&240|i|i<<4}R(x,e)}function W(x,e){G[x&7]=e&255,P[x&7]=J[e&255],H()}function X0(){var x=D>>6}function H(){k=N}this.drawScanline=x=>{x==Q&&E&8&&(F.retryInterrupts=!(E&4),this.probe&&this.probe.logInterrupt(h),F.interrupt(h)),x0?(K[x]=0,_(x),k--):K[x]&&(K[x]=0,_(x))},this.init=(x,e,s,f,w)=>{F=e,r=s,I=f,U=w,O=Z(new $().decode(x0(atob(l0))),8192),d?B={read:S([[16384,32767,16383,function(t){return r[t]}],[53248,57343,4095,function(t){return r[t+16384]}],[0,45055,65535,function(t){return b?b[t]:0}]]),write:S([[16384,32767,16383,R],[53248,57343,4095,function(t,i){R(t+16384,i)}],[0,16383,16383,q]])}:B={read:S([[0,8191,8191,function(t){return O[t]}],[8192,16383,8191,function(t){return b?b[t]:0}],[16384,20479,4095,function(t){return j++,r[t]}]]),write:S([[16384,20479,4095,R],[0,16383,4095,q]])},C={read:function(t){t&=31;var i;switch(t){case 8:i=Y,Y=0;break;default:i=I[t];break}return i},write:function(t,i){switch(t&=31,i&=255,t){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:W(t,i);break;case 9:D=i,X0(),H();break;case 10:u=d?i:i>>1,H();break;case 11:var p=F.saveState();W((p.BC>>8)-1,B.read(p.HL));break;case 12:a=i,l=0,X=0,c=!1;break;case 13:h=i;break;case 14:E=i;break;case 15:Q=d?i:i>>1;break;case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:U.setACRegister(t,i);break;case 24:var p=F.saveState();U.setACRegister((p.BC>>8)-1,B.read(p.HL));break;case 25:m=i;break;default:console.log("IO write",o(t,4),o(i,2));break}}},x.connectCPUMemoryBus(B),x.connectCPUIOBus(C),this.membus=B,this.iobus=C;for(var n=0;n<8;n++)W(n,n)},this.resetWaitStates=function(x){var e=x{F.loadState(x.c),r.set(x.ram),P.set(x.palette),G.set(x.palinds),a=x.magicop,m=x.xpand,c=x.xplower,l=x.shift2,D=x.horcb,E=x.inmod,Q=x.inlin,h=x.infbk,u=x.verbl,X=x.rotcount,g.set(x.rotdata),Y=x.intst,I.set(x.inputs),H()},this.saveState=()=>({c:F.saveState(),ram:r.slice(0),inputs:I.slice(0),palette:P.slice(0),palinds:G.slice(0),magicop:a,xpand:m,xplower:c,shift2:l,horcb:D,inmod:E,inlin:Q,infbk:h,verbl:u,rotcount:X,rotdata:g.slice(0),intst:Y}),this.reset=()=>{a=m=E=Q=h=l=D=0,u=N,c=!1},this.toLongString=x=>{var e="";e+=` INLIN: `+x.inlin,e+=` VERBL: `+x.verbl,e+=` MAGICOP: $`+o(x.magicop),e+=` @@ -11,4 +11,4 @@ XPLOWER: `+x.xplower,e+=` INTST: $`+o(x.intst),e+=` Palette: `;for(var s=0;s<8;s++)e+=o(G[s]);return e+=` `,e},this.connectVideo=function(x){L=x},this.loadROM=function(x){b=x},this.loadBIOS=function(x){O=x},this.getVisiblePixelWords=function(){return u*V}},T=class extends n0{constructor(F){super();this.cpuFrequency=1789e3;this.numTotalScanlines=262;this.sampleRate=60*262*a0;this.cpu=new t0,this.psg=new o0(new r0),this.audioadapter=new s0(this.psg.psg,a0,this.sampleRate),this.handler=F0(this.inputs,C0),this.defaultROMSize=F?45056:8192,this.ram=new Uint8Array(F?20480:4096),this.numVisibleScanlines=F?204:102,this.canvasWidth=F?320:160,this.cpuCyclesPerLine=this.cpuFrequency/(60*this.numVisibleScanlines*1.286)|0,this.m=new m0(F),this.m.init(this,this.cpu,this.ram,this.inputs,this.psg)}read(F){return this.m.membus.read(F)}write(F,r){this.m.membus.write(F,r)}connectVideo(F){super.connectVideo(F),this.frontbuffer=F,this.backbuffer=new Uint32Array(F.length),this.m.connectVideo(this.backbuffer)}preFrame(){this.m.resetWaitStates(0)}postFrame(){var F=this.m.getVisiblePixelWords();this.frontbuffer.set(this.backbuffer.slice(0,F),0),this.frontbuffer.fill(0,F)}setPaddleInput(F,r){switch(F){case 0:this.inputs[28]=r&255;break;case 1:this.inputs[29]=r&255;break}}startScanline(){this.audio&&this.audioadapter.generate(this.audio)}drawScanline(){var F=this.scanline;this.m.drawScanline(F)}advanceCPU(){var F=super.advanceCPU(),r=this.m.resetWaitStates(this.scanline);return r&&(F+=r,this.probe.logClocks(r)),F}loadROM(F){super.loadROM(F),this.m.loadROM(this.rom),this.reset()}loadBIOS(F){this.m.loadBIOS(Z(F,8192)),this.reset()}reset(){super.reset(),this.m.reset()}loadState(F){this.m.loadState(F)}saveState(){return this.m.saveState()}getDebugCategories(){return["CPU","Stack","Astro"]}getDebugInfo(F,r){switch(F){case"Astro":return this.m.toLongString(r)}}},o0=class extends i0{setACRegister(F,r){switch(F&=7,r&=255,F){case 0:this.psg.setClock(1789e3*16/(r+1)),this.psg.writeRegisterAY(7,7^255);break;case 1:case 2:case 3:var B=(F-1)*2,C=r*2+1;this.psg.writeRegisterAY(B,C&255),this.psg.writeRegisterAY(B+1,C>>8&255);break;case 5:this.psg.writeRegisterAY(10,r&15);break;case 6:this.psg.writeRegisterAY(8,r&15),this.psg.writeRegisterAY(9,r>>4&15);break}}};var J=[0,2368548,4737096,7171437,9539985,11974326,14342874,16777215,2425019,4784352,7213567,9582079,12016383,14384895,16753663,16762879,4784304,7143637,9568761,11937279,14306047,16740095,16749311,16758783,6946975,9306307,11731175,14096639,16465151,16736767,16745983,16755199,8847495,11206827,13631696,15994612,16724735,16733951,16743423,16752639,10420330,12779662,15138995,16713687,16723195,16732415,16741631,16751103,11534409,13959277,16318610,16713142,16722394,16731647,16741119,16750335,12255269,14680137,16711790,16713362,16722615,16732123,16741375,16750847,12517376,14876708,16711752,16714605,16724113,16733366,16742874,16752127,12255232,14680064,16711715,16716871,16726380,16735632,16745141,16754393,11534336,13959168,16318464,16720164,16729416,16738924,16748177,16757685,10420224,12779520,15141888,16723971,16733479,16742731,16752240,16761492,8847360,11206656,13639168,16007680,16738058,16747310,16756563,16766071,6946816,9309440,11743488,14112256,16480768,16752151,16761659,16770911,4784128,7151872,9585920,11954688,14323200,16757509,16766761,16776270,2429184,4797696,7232e3,9600512,12034816,14403328,16771870,16777027,9472,2377984,4746496,7180800,9549312,11983616,14352155,16777023,14080,23296,2326528,4695040,7129344,9497856,11927326,14286659,18176,27648,36864,2405376,4774144,7142661,9568041,11927374,21760,30976,40192,246272,2614784,4980503,7405371,9764703,24320,33536,43008,52224,716810,3079982,5504851,7864183,25856,35328,44544,53763,63271,1572683,3932016,6291348,26624,35840,45312,54564,63816,393068,2752401,5177269,26112,35584,44835,54343,63596,65424,2031541,4456409,24832,34084,43592,52845,62353,65462,1834970,4194302,22565,31817,41326,50578,60087,65499,2031615,4456447,19273,28781,38034,47542,56794,393215,2752511,5177343,15466,24718,34227,43479,52987,1569535,3932159,6291455,10887,20395,29648,38900,703743,3072255,5505023,7864319,6047,15299,24807,230655,2599167,4967935,7401983,9764863,688,10197,19449,2388223,4756735,7125503,9559551,11927551,187,5088,2308095,4676607,7110911,9479423,11913727,14282239];for(M=0;M<256;M++)B0=J[M],J[M]=e0(B0)|4278190080;var B0,M;var l0="TFpHAAAgAAAAFHUyA4UHAUpdY2XzIQAgfv5Vyg0AwwAgMc5PzR4JIQUgfiNmb+kAZRrl9cXV3eX95SEAADnlzc4H4f3h3eHRwfHhyUztacnd5d1jEd053X4Gyw8mAN1+BN2OBSdvyxTd4ckBCwjts8kAQ15cJVJTOy83ODkqNDU2LTEyMysmMC49XRtuZR9lH2UeZQjD4ALD4QIgCAgBB2IToAQGAQU+FT9lAfv1xdXl/eUB1U8KPAIB1mWj12Wj2GWi/SHrT/00AP1+ANY8ICL9NgAAIexPNP0h40/9ywD+/SHtXQgWBCHuTzQ61E+3KBL9IepPYw23KAX9NQAYA82VCf3hXUIt7U1dRikOXUIktyhG3csERig5EdVPaSYAGX63KC4+1YFfPk/OAFch1U8GAAl+3YYFErcgF0H1HgHxBBgCyyMQ/P0h+l0CVrP9dwBjNz4MGLTd4cllASEP/+XNhwLxycnB4eXFEQYAGUY+//UzxTNjjV0GcvXdTgTdRgUhDAAJ4+HlXiNWGm8+ApUwCcXFzc4H8cEY6xNL4eVxI3Ld+V0CTl0DQgoAGU4jZmnDqhxdEj1pYGNZXiNW4eVzI3JdBEvWCChdB0ntXQRCXWgkXgTdVmNzGU1E610FM3sCA3oCYx5dB1j1XQge3XX+3XT/3W7+3Wb/TiNG3csGbigi1f3h/SP9IwpvAzMzxf11AF0FCP0j4eVuwcUDYwpjIE4oC/0hBAD9GQoDXSMkBlZjSQVdCQleY0kGXQkJZmNJB10JCXZjSQldCQl+KB79IQpjSV0GdP0hC2MH4eVeXQJxcwBdBKJxI3BdA/DRwcXVxf3h/VYH1TPFzaYD8TPJAaYEeO1H7V77PsjTDz6m0w0+CNMOzeICw+MCGAJjaGlgEQUAGX7TCmMBB2NBCWMBCWNBDl0siXIAXSdNXSOIYx8EXSNI1f3hYwQGY4RpYAEJAAlu/eXBJgDV5cXNqxwhBgA5XQKUIetPTjrrT5Eo+l0olV0k0AcACV5TFXJ7tygHxc0UBV0ivV0olV0kk2tiAQQACU4jRl0ic24K/WYL5f3h610FbNX95cXN1l0HYV0nzztdFjRdJN1jR34H3Xf9HgDdVv3dNf16tyglXSRIVt00/iAD3TT/CmfFe/Uz5TPVM81WAPEzwVx9AgMY0V0jZF0HX/0h70/9RgD9XgH9VgIOAPE+BcsgyxPLEj0g9/1+AKn9dwD9fgGo/XcB/X4Cq/13Av1+A6r9dwP1/U4C/UYDEQAA8cs4yxldGyP9TgD9RgH9XgL9VgNdAlghyxBdBFr1XRovXSVXCQAJTUQKtyAGYyQCGBtfFgAhAADF5dUq8U/lKu9P5c0lHfFlAcF9XWoMY/RdQ3QJ/V4A/VYBXQVAbyYAGV1Cf3QBfl0bKAFpYMVdQgPBbiYAKV0FKgNlAV1xeF0loF0jiAbdd/9rYgEKXSOp3W7/yz0mYwMhCQAZ3cv/RigJeQdlAeYPGAN55g93M11PIGNhTURdAkJeByF4ABYAGV0Dnl1F4GMVfjLUT12EPH79Ic5P/XcAI379dwFpYCNl4SHQXQcJIepPNgDJIdRlol1JSX4E3Xf+3X4F3Xf/3X7+xgxv3X7/zgBn5U4jRuFZUBNzI3IK3Xf9T8s53cv9figbKvtdok9eBgBdIqr9Kv1P/Qn9bgD9ZgEYFQYAaWApCRFeCBlNRCMjXmlgfiNmb2MuRigR5Xv1M91O/t1G/11kvOFdBgWqHF1DcgEDADYDADcDgEYDgIADAIIDgHgEEIsEAO0CCJAH4MgHAKgEVMgEgNcEXqsPXoEDoC8cxvAbxj0Z3oEDZUEmgQOWgQOegQOGZaG8F06bF47mF2MHRmVDqGMoawcAaAsGPw6AyQ6AgQMAY6KYYyUfBRCBAw6BA4AmB4hloeoGwLoGwEMFYzQAfQWWY6JlVOQFQGOBwF0DQ44h8v85+SHOTwYZr3cjdyMQ+SEAAOXNiwTxPsDTCj4p0wldgptKBAD7aAvxIQ4AOfnJKs5PTl0jqTQAIAP9NAFpyV0jpl0FBipjAyECAP05/X4Ad8ljBk5lYSsi0E9pye1L0E8Kxv8Cb11IZ81SCd11/33WgNJRCt1+/zLqTyHUT07LQSgIxWMTwX3TF8tJXQcEFMtRKA4qzk9+0xO3KAU600/TFctZKAxdCoTLYSgNY5oStyAEee4QT8tpXQ0ZcV0FGRFjmUBPy3ldDxkIOtJP5g9HGAIGAMthKAdjRvAYAj4AsNMWw2QL3X7/1ogwH10Csn7/BgDGkE94zv9BDgAmAH2xb3ywZ81SAF0GHiAnT3nWCNJkC10DuVkGAD4Xk18+AJhXYySzb3yyZ2MQAMEMGNpjJubwT9aQKB15/qAoJf6wKDD+wChC/tAoYv7gKHHW8MpXC8NkC2M+/SHUT/11XQVaxmFHxTPNZAkzXQYU0mNUY4LTY0IYZs2LCX23KAxdIqsjRu1Dzk8YUyHOT37GAncjfs4Ad81+CRhCXQJ1D09jT4FjzhgvYwvW4SAo0xU+ANMWYzV+MupPXSYdEv00ARgNYxFjlV1jj11q9SHr/zn53TbwAN0272Vh8l2C2jnddfnddPrdbvndZvrbEHfdfvnGAd139d1++s4A3Xf23W713Wb22xFjkQLdd/ddBRH43W733Wb42xJjkQPdd/NdBRH03W7z3Wb02xN33TbxAGMV3Ybxb2OUZ37dd/vdfvHG5N13/D4Azk/dd/3dbvzdZv3dfvuWKDpjE4fGFd138F0THH7drvvLZygD3TRjGF0MTe/dNPFjLNYEOJAR5E9dBMMBBADtsGPD2xR3XQW+FWMBXQOuFmMBXQOeF3ddg6X8XYOl/d1+/F2Dsf3dd/8OXQK0gV9dA11XGke3KC1dxO0jZQF+I2aBb3xdAnWgErcoFEEEGm+3KAoEZQF9yz8SGPHdcPIMedYEOL3dfvK3KB5KAwKTfgDdlvIoEmMK/XcAZaFdAq828BMYKWNcICNdBRy3KBn9ywB+KAZjFBEYBGWhEl0ipWMVNgBdBcYcXQbGHV0Gxh5dBsYfdw5dBR4GAAlGEd9KAwK6XniTKAl5xhxdIlFw710DkNtdIjpdAuH63Xf/Yx9dBNJdIyv9Id5dBIAzZaHdd+8GB93L734oHnjGCWM59Q5KBALqIRD8XQUhXeJPGGNcJgUY1UoFAv5dHDVj4V0LNd1+8NYSOAUh7E82/91+/MYJT91+/c4AR2MQAmNIB10HCO8CSgsAUyH5XULPXeS+CgAJSgoClF4jVjMzXcbM3Xf70dUab911/X3WwDBG3X795j9dI/P73Zb8IC7h5SNjJ2PwcyNyY1fAKAr+QCgG1oAoCRgWxc03A/EYD8XNRmXBCBMTEzMz1RiwXQuCSggAQ+vFXeKfBxLFzT8O8UoMAz1+BA8PXQRxTgXLOcs53V4GFgBrYikpGSkpKREAQBndXvwWSgcDW34E5gNfIacPYwpG3X78kSAEPgEYAa/dd/23XUJFBV0HFn4vX3ijR10F73gvV3uiX3jdpgezY8p33X79tyAw3V7+3Vb/E91G/AR4kTAH3X4HEhMY9BpPXQNBxqdvPg/OAGdGeaBPeC9jNLESXQPW/z8PA10nZF3CjV0F3wVdImT43XT53W743Wb5fl2CFXH+3XD/3XH83XD93XH63XD73XH13XD2XQca9N138t028wBdRLsRBwAZTgYA4eUJ3X73BgCVeJziGBDugPJVEF0Erl0ir05dZPcRBF0C+W763Wb7SgMCyHiDV3n1M2Mv9TPVM8UzzesO8fHdNPcYlV1ME9ddAqddYtrsXWPa7d1u7N1m7REFABlOI0ZdI3Jjym4mAHuVX3qcV91+7MZKBAC27V2Cxl1FQGMXxeXVzZAc8fHBCd115d105gEAAN1eCF0osgndTgddIsdZXSO08N108d1+B+YDy99P3X4J5jCx3XfkY0HAY4cPR3m3ygQTIQVdonj03XT13X70xgBf3X71zsDdc9rdd9tjHgdjN/XdNtkB8TwYBN3L2SY9IPljYAFdQ631XQKX/WMf5oDdd+djEN13+mMOXaNbYwT4Y4RjKPxdor1dgsr3edbAXUc2791w7t1+5d136t1+5t1369022EoFBR3dftiW0kQTPgjTDD4M0xndftpdAmno3X7bXQJp6d1u6t1m607dNOogA900691u2t1m23HdbujdZulx3X7ntyhF3W703Wb1ft1312N1A10i6mP1891O2t1G2wMDXaXKAt1u8t1m83dj/d1+12MCXQJAY4J+77fKohJdDERdYvvbXWP72sYGX2OEV11EDF2ijRICY1AFXQkcBF0HHF1Cd2PbXQV7A91e2t1W2xMT3W723Wb3Y1JdE37u0xkOAHndltkwT91+5NMMHgB7Y0UjXQSRXWOObvDdZvFwZcQjcCNdJPUcGNfdbtkmACk+KJVfPgBdQlHwg13E1Irdd/EMGKvdNNjDjxF40xndTuXdRuYeXSV4VnuSMCoKVwNdA2ZdBE1yZcQjciM2ACN9xiVjP3xdIkjxHBjLXUS3I25dRShH9V2jWyUQ/F1jAEoFCWEgZQFloVBQY4ZI/EhIZWEgeIBwCPAgAEgQIECQAGCQYKCokGhgYGMhYyNAZQIgQGNxIEAAqHD4cKhjf/hdAkBlAWBjDQAA8F0FVwBgYAAIYz6AAHCIiKiIiHAgYGNwcHCICDBAgPhlwXAIiHAQMFCQ+BAQ+ICAY0ZwiIDwYyL4iBBjo2MDZUFlYXhjFAAAYGUhZQFlwSBAXQJRQCAQAAD4ZSEAYwJdAmNwCAgwIABjMLiokIBjcPiIiIjwZURwiICAgIhwYwNjTPiAgPCAgPhlxIBjFLBdA2RjqXBdA9hwCGUBY02QoMCgkGN1ZQH4iNioY7nIqKiYY+ZloV0CV2O+iKiokGhjRpCQYzFdA8r4XQNFIGOhXQNaiIhQY4ao2GODUGPKZQH4XSMl+HBdI11wAF0C1ggAcBBlAnAgcKhdJKVA+EBlwiAgqHAgACAQ+BBjBmO+Yw0A+GVhZQNAQABAAKCgYwJg8PBgAEDg4EAAkF0iyMCw4NBjPV0kxCAAQF0iv0DgQGMiZaFdJLsAAOBj/ABjFUAA4KCgoODAQEBjPCDggGWBYCBjC+AgY0Ug4GWBoGMMY1egY0JjEeBjMkBjd2AgACBdAqXgZSEAQCBAAGM0AEDwkBDQ8GBjJQDAYyYAYICA4ADAoKDAAODAYwJlgYBjDGMRoGNb4EBAYxsgY0fAwKAAgGNl4OBjUaCgZYNjB6DggGWC8GWBYxvggGBjDEBAXQL3Y77AgACgYysAoEBjKqBjEgDgIF0CTUBAYABAQCAgAGAgXQKPXSIkZQLwgF0E/2M0XQLTYwKA4EoHCbNd459KEwIP3V4G3VYHGkcTeLcgE2MRxgRKBwCPCALDWxd41iAwJCEGAk1E1d1mCt1uCeXdVggeINXFzVoQ8fHx0WMfhd13CBi9eNZkMCNdBxx+CPUzxTNjMOVdDSCVeNaAOJBKBgJzfiNmb+X94V0NL/1dDS3DuhZKEQCPxf3h/V4GaWAjZQFWY0VmBUoFCa3dbgbdZgflxc2SFiEHSgwKFkoHCrxKBAwM1cXNYBfxSgsAyWWhOetdCFp+CRJrYiM2AGOiXeyESgMAM10iT/tdI0/83W773Wb8XeLRfl3ComPGBWOG+l0FBgZjhvhdBQYHY4b35j9dw8v35kDdd/+3KAshDQLddf3ddP4YCSEGXQUDXSOl9N1+/koDBMNjHgQegBgCHgDdc/NjcoBdwo1dBE1KAwuwRt1e9hYAe8b/3Xf9es5lof7dbv3dZv7dy/5+KAJrYsssyx0JXQVSXvZLHXm3KGhj2n7LQygJSgQJZk8YEGWBY88rY+V5tyAKSgMD/AQOEBgESgMFaysZBgAJTnndhvNH1d1m+N1u+uXdfvldIr9dxEtdKMT5hd13+RiSXSM9MDEyMzQ1Njc4OSorLC0uLyBdR6Mh510iT0oLChPoSgYLrOljQU4Ea2JdIuxKBQvSCXnmA7Xdd+dKBg3fXSIKcvRYSgoCewAZ3XXu3XTv3X7nXSJc+3lKBAKp8N1++7coBz4n3ZbwGAPdfvDdd+1jWwhjk+5dYyfvXWInNusA3X7r3Zbp0usbYxnTDN1+7V0igDb2YxDwt8r5Gt1+80oDBkNKAwChNuwA3W7oJgAp3X7sXSJyNv9jH/6V3X7/nOInGu6A8l8bSgQE4X7dd+rdNPcgA900+F0DhFzdfvXdlv7dd/Hdfvbdnv9dIs5+/N2G8V1CSH793Y7yXUND+d1m+t1+6nfdfvFdItpjE/JdItxjDGMk+V0GJPpdCyQYUl0CVIb+Y5b23Y5dCijxXQYo8t1u8d1m8mNo3TT5XQKQXRtM3TTsZUHDChpKAwBK6DBt3XH53Tb6AN1e891W9BNKBAW9Rl0D0iFdA9L5b10D0Ppn3X78hWME/YxnXSSncBgfY1mGY9mO+md93Yb8b3zdjv1dBhkMGJzdfvdKAweP+F1iAk7sXQZlXQJXLl0EV10mMV0Dw10lMV0E1fJdB9U2ABgsXQRkXSYDXQPNXRXfNgBjEsYoXUME/UoEApo068PbGV2LAkoGEKIKSgYQ50oDD+gJGm8TSgMPsgddBwRKAxC2xc09XQ03O0oXBeVKAxBTCUoDBnX9Yzvdfv2V/XcASgMQWF0PDkoHBeLFzfAbXQNZ8cHR1cX1r2+wBhAgBAYIeSnLERcwARkQ98npSgwNON1OCN1GCWlgC3y1KAfdfgYSExjy3W4E3WYFSg4F413IPGPxXWKX/t1dYpT/XQo9E10EhX5KBg9JEhMY5uHlXQvuAWWBfgsHOEDdywgm3csJFt3LCmVhCxZdAl6WCF0CXp4JXQJYngpdAlieCzASYxY+Yx4eYyZlYQgeGAQESBi6XRYoOCRdBRJ3BF0FFXddA6hjGHcGY9vddwddDkxBDXi3IKxdBfVd4xRKCAJvZR9lH2UfZR9lG2UB";var D0=[{id:"01-helloworlds.asm",name:"Hello World (ASM)"},{id:"02-telephone.asm",name:"Telephone (ASM)"},{id:"03-horcbpal.asm",name:"Paddle Demo (ASM)"},{id:"hello.c",name:"Hello Graphics"},{id:"lines.c",name:"Lines"},{id:"sprites.c",name:"Sprites"},{id:"vsync.c",name:"Sprites w/ VSYNC"},{id:"fastsprites.c",name:"Fast Sprites"},{id:"music.c",name:"Music"},{id:"rotate.c",name:"Rotate Op"},{id:"rainbow.c",name:"Rainbow"},{id:"cosmic.c",name:"Cosmic Impalas Game"},{id:"racing.c",name:"Pseudo 3-D Racing Game"}],E0=[{id:"bios.c",name:"BIOS"}],v=class extends d0{constructor(){super(...arguments);this.getMemoryMap=function(){return{main:[{name:"BIOS",start:0,size:8192,type:"rom"},{name:"Screen RAM",start:16384,size:4096,type:"ram"},{name:"BIOS Variables",start:20430,size:20480-20430,type:"ram"}]}}}newMachine(){return new T(!1)}getPresets(){return D0}getDefaultExtension(){return".c"}readAddress(F){return this.machine.read(F)}showHelp(){return"https://8bitworkshop.com/docs/platforms/astrocade/"}},f0=class extends v{getPresets(){return E0}loadROM(F,r){this.machine.loadBIOS(r)}},c0=class extends v{constructor(){super(...arguments);this.getMemoryMap=function(){return{main:[{name:"Magic RAM",start:0,size:16384,type:"ram"},{name:"Screen RAM",start:16384,size:16384,type:"ram"}]}}}newMachine(){return new T(!0)}};y.astrocade=v;y["astrocade-bios"]=f0;y["astrocade-arcade"]=c0; -//# sourceMappingURL=astrocade-VLTUF6PT.js.map +//# sourceMappingURL=astrocade-HTRRXIK3.js.map diff --git a/gen/astrocade-VLTUF6PT.js.map b/gen/astrocade-HTRRXIK3.js.map similarity index 100% rename from gen/astrocade-VLTUF6PT.js.map rename to gen/astrocade-HTRRXIK3.js.map diff --git a/gen/atari7800-LNLQFL4H.js b/gen/atari7800-TFVORQV6.js similarity index 97% rename from gen/atari7800-LNLQFL4H.js rename to gen/atari7800-TFVORQV6.js index e3b1ec1b..a19f2cc9 100644 --- a/gen/atari7800-LNLQFL4H.js +++ b/gen/atari7800-TFVORQV6.js @@ -1,7 +1,7 @@ -import{I as $,h as H,k as z,p as K,t as Y}from"./chunk-4UNLDFGJ.js";import{$ as T,J as U,U as L,V as o,W as E,Y as N,_ as W,da as F,g as p}from"./chunk-47V4PEOO.js";import"./chunk-5XVCUSSZ.js";var g=0,B=2,C=8,Q=N([[o.A,C+0,128],[o.B,C+1,128],[o.GP_A,C+0,128],[o.GP_B,C+1,128],[o.SELECT,B,-2],[o.START,B,-1],[o.UP,g,-16],[o.DOWN,g,-32],[o.LEFT,g,-64],[o.RIGHT,g,-128],[o.P2_A,C+2,128],[o.P2_B,C+3,128],[o.P2_UP,g,-1],[o.P2_DOWN,g,-2],[o.P2_LEFT,g,-4],[o.P2_RIGHT,g,-8]]);var D=263,j=258-16,v=451,Z=28,tt=16,et=24,V=2,G=D*60*V,R=class{constructor(){this.regs=new Uint8Array(32)}reset(){this.regs.fill(0)}read(t){return this.regs[t]|0}write(t,e){this.regs[t]=e}saveState(){return{regs:this.regs.slice(0)}}loadState(t){for(let e=0;e<32;e++)this.write(e,t.regs[e])}static stateToLongString(t){let e="";return e+=L(t.regs,0,32),e}},_=class{constructor(){this.cycles=0;this.regs=new Uint8Array(32);this.offset=-1;this.dll=0;this.dlstart=0;this.dli=!1;this.h16=!1;this.h8=!1;this.writemode=0;this.indirect=!1;this.pixels=new Uint8Array(320);this.WSYNC=0}reset(){this.regs.fill(0)}read(t){return this.regs[t]|0}write(t,e){this.regs[t]=e,t==4&&this.WSYNC++}saveState(){return{regs:this.regs.slice(0),offset:this.offset,dll:this.dll,dlstart:this.dlstart,dli:this.dli,h16:this.h16,h8:this.h8,indirect:this.indirect,writemode:this.writemode}}loadState(t){for(let e=0;e<32;e++)this.write(e,t.regs[e]|0);this.offset=t.offset|0,this.dll=t.dll|0,this.dlstart=t.dlstart|0,this.dli=!!t.dli,this.h16=!!t.h16,this.h8=!!t.h8,this.indirect=!!t.indirect,this.writemode=t.writemode|0}isDMAEnabled(){return(this.regs[28]&96)==64}getDLLStart(){return(this.regs[12]<<8)+this.regs[16]}getCharBaseAddress(){return(this.regs[20]<<8)+this.offset}setVBLANK(t){t?(this.regs[8]|=128,this.offset=-1,this.dll=this.getDLLStart(),this.dli=this.bus&&(this.bus.read(this.dll)&128)!=0):this.regs[8]&=~128}readDLLEntry(t){if(this.dll>=16384)return;let e=t.read(this.dll);this.offset=e&15,this.h16=(e&64)!=0,this.h8=(e&32)!=0,this.dlstart=(t.read(this.dll+1)<<8)+t.read(this.dll+2),this.dll=this.dll+3&65535,this.dli=(t.read(this.dll)&128)!=0}isHoley(t){return this.indirect?!1:!!(t&32768&&(this.h16&&t&4096||this.h8&&t&2048))}readDMA(t){return this.isHoley(t)?0:(this.cycles+=3,this.bus.read(t))}doDMA(t){this.bus=t,this.cycles=0;let e=this.pixels;if(e.fill(this.regs[0]),this.isDMAEnabled()){this.cycles+=this.offset==0?et:tt,this.offset<0&&this.readDLLEntry(t);let c=this.dlstart&65280,a=this.dlstart&255;do{let u=t.read(c+(a+0&511)),s=t.read(c+(a+1&511));if(s==0||c>=16384)break;let y=t.read(c+(a+2&511)),b=t.read(c+(a+3&511)),d=!1;if((s&31)==0){var i=b>>5,f=32-(b&31),r=t.read(c+(a+4&511));d=(s&32)!=0,a+=5,this.cycles+=10,this.writemode=s&128}else{var r=b,i=s>>5,f=32-(s&31);a+=4,this.cycles+=8}this.indirect=d;let m=u+((y+(d?0:this.offset)&255)<<8);r*=2;let S=this.regs[28],M=(S&3)+(this.writemode?4:0),A=(S&4)!=0,I=d&&(S&16)!=0;I&&(f*=2);for(var x=0;x>1):m+x);if(d){let w=(this.regs[20]+this.offset<<8)+h;I&&x&1&&(w++,this.cycles-=3),h=this.readDMA(w)}switch(M){case 0:for(let n=0;n<4;n++){let l=h>>6&3;(l||A)&&(e[r]=e[r+1]=this.regs[(i<<2)+l]),h<<=2,r=r+2&511}break;case 3:for(let n=0;n<8;n++){let l=(h&128)>>6;(l||A)&&(e[r]=this.regs[(i<<2)+l]),h<<=1,r=r+1&511}break;case 4:for(let n=0;n<2;n++){let l=(h>>6&3)+(h&12);(l&3||A)&&(e[r]=e[r+1]=e[r+2]=e[r+3]=this.regs[((i&4)<<2)+l]),h<<=2,r=r+2&511}break;case 6:for(let n=0;n<4;n++){let l=(h&128)>>6|(h&8)>>3;(l||A)&&(e[r]=this.regs[(i<<2)+l]),h<<=1,r=r+1&511}break;case 2:for(let n=0;n<8;n++){let l=(h&128)>>6;l+=n&1?i&1:i>>1&1,(l||A)&&(e[r]=this.regs[(i<<2)+l]),h<<=1,r=r+1&511}break;case 7:let w=h;for(let n=0;n<4;n++){n==2&&(w<<=2);let l=(h&128)>>6,J=i&4|w>>2&3;(l||A)&&(e[r]=this.regs[(J<<2)+l]),h<<=1,r=r+1&511}break}}}while(this.cycles=16384)return;let e=t.read(this.dll);this.offset=e&15,this.h16=(e&64)!=0,this.h8=(e&32)!=0,this.dlstart=(t.read(this.dll+1)<<8)+t.read(this.dll+2),this.dll=this.dll+3&65535,this.dli=(t.read(this.dll)&128)!=0}isHoley(t){return this.indirect?!1:!!(t&32768&&(this.h16&&t&4096||this.h8&&t&2048))}readDMA(t){return this.isHoley(t)?0:(this.cycles+=3,this.bus.read(t))}doDMA(t){this.bus=t,this.cycles=0;let e=this.pixels;if(e.fill(this.regs[0]),this.isDMAEnabled()){this.cycles+=this.offset==0?et:tt,this.offset<0&&this.readDLLEntry(t);let c=this.dlstart&65280,a=this.dlstart&255;do{let u=t.read(c+(a+0&511)),s=t.read(c+(a+1&511));if(s==0||c>=16384)break;let y=t.read(c+(a+2&511)),b=t.read(c+(a+3&511)),d=!1;if((s&31)==0){var i=b>>5,f=32-(b&31),r=t.read(c+(a+4&511));d=(s&32)!=0,a+=5,this.cycles+=10,this.writemode=s&128}else{var r=b,i=s>>5,f=32-(s&31);a+=4,this.cycles+=8}this.indirect=d;let m=u+((y+(d?0:this.offset)&255)<<8);r*=2;let S=this.regs[28],M=(S&3)+(this.writemode?4:0),A=(S&4)!=0,I=d&&(S&16)!=0;I&&(f*=2);for(var x=0;x>1):m+x);if(d){let w=(this.regs[20]+this.offset<<8)+h;I&&x&1&&(w++,this.cycles-=3),h=this.readDMA(w)}switch(M){case 0:for(let n=0;n<4;n++){let l=h>>6&3;(l||A)&&(e[r]=e[r+1]=this.regs[(i<<2)+l]),h<<=2,r=r+2&511}break;case 3:for(let n=0;n<8;n++){let l=(h&128)>>6;(l||A)&&(e[r]=this.regs[(i<<2)+l]),h<<=1,r=r+1&511}break;case 4:for(let n=0;n<2;n++){let l=(h>>6&3)+(h&12);(l&3||A)&&(e[r]=e[r+1]=e[r+2]=e[r+3]=this.regs[((i&4)<<2)+l]),h<<=2,r=r+2&511}break;case 6:for(let n=0;n<4;n++){let l=(h&128)>>6|(h&8)>>3;(l||A)&&(e[r]=this.regs[(i<<2)+l]),h<<=1,r=r+1&511}break;case 2:for(let n=0;n<8;n++){let l=(h&128)>>6;l+=n&1?i&1:i>>1&1,(l||A)&&(e[r]=this.regs[(i<<2)+l]),h<<=1,r=r+1&511}break;case 7:let w=h;for(let n=0;n<4;n++){n==2&&(w<<=2);let l=(h&128)>>6,J=i&4|w>>2&3;(l||A)&&(e[r]=this.regs[(J<<2)+l]),h<<=1,r=r+1&511}break}}}while(this.cycles(this.xtracyc++,this.readInput(t))],[0,31,31,t=>(this.xtracyc++,this.tia.read(t))],[32,63,31,t=>this.maria.read(t)],[64,255,255,t=>this.ram[t+2048]],[256,319,255,t=>this.read(t)],[320,511,511,t=>this.ram[t+2048]],[640,767,127,t=>(this.xtracyc++,this.readPIA(t))],[6144,10239,65535,t=>this.ram[t-6144]],[10240,16383,2047,t=>this.read(t|8192)],[16384,65535,65535,t=>this.rom?this.rom[t-16384]:0],[0,65535,65535,t=>this.probe&&this.probe.logIllegal(t)]]),this.write=T([[21,26,31,(t,e)=>{this.xtracyc++,this.pokey1.setTIARegister(t,e)}],[0,31,31,(t,e)=>{this.xtracyc++,this.tia.write(t,e)}],[32,63,31,(t,e)=>{this.maria.write(t,e)}],[64,255,255,(t,e)=>{this.ram[t+2048]=e}],[256,319,255,(t,e)=>{this.write(t,e)}],[320,511,511,(t,e)=>{this.ram[t+2048]=e}],[640,767,127,(t,e)=>{this.xtracyc++,this.writePIA(t,e)}],[6144,10239,65535,(t,e)=>{this.ram[t-6144]=e}],[10240,16383,2047,(t,e)=>{this.write(t|8192,e)}],[49151,49151,65535,(t,e)=>{}],[0,65535,65535,(t,e)=>{this.probe&&this.probe.logIllegal(t)}]]),this.connectCPUMemoryBus(this),this.dmaBus=this.probeDMABus(this),this.handler=E(this.inputs,Q),this.pokey1=new H,this.audioadapter=new z(this.pokey1,V,G)}readConst(t){let e=this.probe;this.probe=null;let i=this.read(t);return this.probe=e,i}readInput(t){switch(t){case 12:return~this.inputs[8]&128;case 13:return~this.inputs[9]&128;default:return this.inputs[t]|0}}readPIA(t){switch(t){case 0:case 2:return this.inputs[t];case 1:case 3:return this.regs6532[t];case 4:return this.getPIATimerValue();default:return 0}}writePIA(t,e){switch(t){case 0:case 1:case 2:case 3:this.regs6532[t]=e;return;case 20:this.setPIATimer(e,0);return;case 21:this.setPIATimer(e,3);return;case 22:this.setPIATimer(e,6);return;case 23:this.setPIATimer(e,10);return;case 24:this.setPIATimer(e,6);return}}setPIATimer(t,e){this.piatimer=t+1<0?t>>this.timerinterval:t&255}advanceCPU(){var t=super.advanceCPU();return this.tickPIATimer(t),this.xtracyc&&(t+=this.xtracyc,this.tickClocks(this.xtracyc),this.xtracyc=0),t}tickClocks(t){this.probe.logClocks(t),this.tickPIATimer(t)}tickPIATimer(t){this.piatimer=Math.max(-256,this.piatimer-t)}advanceFrame(t){var e=this.pixels,i=0,f,r=0,x=0,c=0;this.probe.logNewFrame();for(var a=0;a>2),r+=y,e){let m=(this.maria.regs[28]&128)!=0?15:255;for(var s=0;s<320;s++)e[i++]=X[this.maria.pixels[s]&m]}}for((u||a==D-1)&&this.maria.doInterrupt()&&(this.probe.logInterrupt(0),this.cpu.NMI());r>2),r=v;break}if(t&&t()){t=null,a=999;break}r+=this.advanceCPU()<<2,c++}this.audio&&this.audioadapter.generate(this.audio),r-=v,x+=r,this.probe.logNewScanline()}return this.lastFrameCycles=x,c}getRasterX(){return this.lastFrameCycles%v}getRasterY(){return this.scanline}loadROM(t){t.length==49280&&(t=t.slice(128)),this.rom=W(t,this.defaultROMSize,!0)}reset(){super.reset(),this.tia.reset(),this.maria.reset(),this.inputs.fill(0),this.inputs[g]=255,this.inputs[B]=1+2+8,this.setPIATimer(0,0)}readAddress(t){return this.read(t)|0}loadState(t){this.cpu.loadState(t.c),this.ram.set(t.ram),this.tia.loadState(t.tia),this.maria.loadState(t.maria),this.regs6532.set(t.regs6532),this.piatimer=t.pia.timer,this.timerinterval=t.pia.interval,this.loadControlsState(t)}saveState(){return{c:this.cpu.saveState(),ram:this.ram.slice(0),tia:this.tia.saveState(),maria:this.maria.saveState(),regs6532:this.regs6532.slice(0),inputs:this.inputs.slice(0),pia:{timer:this.piatimer,interval:this.timerinterval}}}loadControlsState(t){this.inputs.set(t.inputs)}saveControlsState(){return{inputs:this.inputs.slice(0)}}getDebugCategories(){return["CPU","Stack","TIA","MARIA"]}getDebugInfo(t,e){switch(t){case"TIA":return R.stateToLongString(e.tia);case"MARIA":return _.stateToLongString(e.maria)+` Scanline: `+this.scanline}}getDebugDisplayLists(){let t={},e=this.maria.getDLLStart(),i=0;for(;i<240;){let f=this.readConst(e),r=f&15,x=(f&64)!=0,c=(f&32)!=0,a=(this.readConst(e+1)<<8)+this.readConst(e+2);e=e+3&65535;let u=(this.readConst(e)&128)!=0,s="DL $"+p(a,4)+" "+i+"-"+(i+r);x&&(s+=" H16"),c&&(s+=" H8"),u&&(s+=" DLI"),t[s]={$$:this._readDebugDisplayList(a)},i+=r+1}return t}_readDebugDisplayList(t){return()=>this.readDebugDisplayList(t)}readDebugDisplayList(t){let e=[],i=t&65280,f=t&255;do{let a=this.maria.regs[28],u=this.readConst(i+(f+0&511)),s=this.readConst(i+(f+1&511));if(s==0)break;let y=this.readConst(i+(f+2&511)),b=this.readConst(i+(f+3&511)),d=!1,m="",S,M=(a&3)+(s&128?4:0);if((s&31)==0){var r=b>>5,x=32-(b&31),c=this.readConst(i+(f+4&511));d=(s&32)!=0,S=s&128,f+=5}else{var c=b,r=s>>5,x=32-(s&31);f+=4}m+="X="+c+" W="+x+" P="+r,S&&(m+=" WM=1"),d&&(m+=" CHR=$"+p(this.maria.regs[20]+this.maria.offset&255)+"xx");let A=u+((y+(d?0:this.maria.offset)&255)<<8);m=" $"+p(A,4)+" "+m,m=["160A","?","320D","320A","160B","?","320B","320C"][M]+" "+m,e.push(m)}while(f<512);return e}},X=new Uint32Array(256);for(P=0;P<256;P++)X[P]=F(P);var P;var rt=[{id:"sprites.dasm",name:"Sprites (ASM)"},{id:"wsync.c",name:"WSYNC"},{id:"sprites.c",name:"Double Buffering"},{id:"scroll.c",name:"Scrolling"}],q=class extends ${constructor(){super(...arguments);this.getMemoryMap=function(){return{main:[{name:"TIA",start:0,size:32,type:"io"},{name:"MARIA",start:32,size:32,type:"io"},{name:"RAM (6166 Block 0)",start:64,size:192,type:"ram"},{name:"RAM (6166 Block 1)",start:320,size:192,type:"ram"},{name:"PIA",start:640,size:24,type:"io"},{name:"RAM",start:6144,size:4096,type:"ram"},{name:"Cartridge ROM",start:16384,size:49152,type:"rom"}]}}}newMachine(){return new O}getPresets(){return rt}getDefaultExtension(){return".c"}readAddress(t){return this.machine.readConst(t)}getROMExtension(){return".a78"}getDebugTree(){let t=super.getDebugTree();return t.display_list=this.machine.getDebugDisplayLists(),t}};U.atari7800=q; -//# sourceMappingURL=atari7800-LNLQFL4H.js.map +//# sourceMappingURL=atari7800-TFVORQV6.js.map diff --git a/gen/atari7800-LNLQFL4H.js.map b/gen/atari7800-TFVORQV6.js.map similarity index 100% rename from gen/atari7800-LNLQFL4H.js.map rename to gen/atari7800-TFVORQV6.js.map diff --git a/gen/atari8-AI5453LS.js b/gen/atari8-YJPSBKKM.js similarity index 98% rename from gen/atari8-AI5453LS.js rename to gen/atari8-YJPSBKKM.js index 45f543f4..0095bd11 100644 --- a/gen/atari8-AI5453LS.js +++ b/gen/atari8-YJPSBKKM.js @@ -1,4 +1,4 @@ -import{a as xt}from"./chunk-7TOHRG6S.js";import{B as ft,I as dt,g as nt,k as ht,q as ot,t as ct,y as lt}from"./chunk-4UNLDFGJ.js";import{$ as C,J as I,O as T,U as y,V as i,W as it,Y as rt,a as v,da as at,g as f,q as _}from"./chunk-47V4PEOO.js";import"./chunk-5XVCUSSZ.js";var Ut=[0,25,17,9],Yt=[0,25+64,17+80,9+96],E=0,Bt=1,j=2,z=3,Ht=4,Qt=5,jt=7,zt=9,L=10,Gt=11,Xt=12,qt=13,ut=14,Wt=15,K=15;var Zt=17-4,$t=110-4,Jt=105,G=[0,0,8,10,8,16,8,16,8,4,4,2,1,2,1,1],te=[0,0,2,2,2,2,4,4,8,4,4,4,4,2,2,2],ee=[0,0,0,0,0,1,0,1,0,0,2,1,0,0,0,0],mt=[0,0,1,1,2,2,2,2,8,4,4,2,2,2,2,1],V=class{constructor(t,e){this.regs=new Uint8Array(16);this.dma_enabled=!1;this.dliop=0;this.mode=0;this.jmp=!1;this.lms=!1;this.dlarg_lo=0;this.dlarg_hi=0;this.period=0;this.scanaddr=0;this.startaddr=0;this.pfbyte=0;this.ch=0;this.linesleft=0;this.yofs=0;this.isfirstline=!1;this.v=0;this.h=0;this.linebuf=new Uint8Array(48);this.dmaclock=0;this.dmaidx=0;this.output=0;this.dramrefresh=!1;this.in_vscroll=0;this.read=t,this.nmi=e}reset(){this.regs.fill(0),this.regs[ut]=0,this.regs[K]=127,this.regs[Xt]=0,this.regs[qt]=255,this.setReg(E,0),this.h=this.v=0,this.startaddr=this.scanaddr=0,this.dmaclock=0}saveState(){return _(0,{},this)}loadState(t){_(0,this,t),this.setReg(E,t.regs[E])}static stateToLongString(t){let e="";return e+="H: "+v(t.h,3)+" V: "+v(t.v,3)+` +import{a as xt}from"./chunk-BMGQJMLR.js";import{B as ft,I as dt,g as nt,k as ht,q as ot,t as ct,y as lt}from"./chunk-GKVIY6GD.js";import{H as I,M as T,S as y,T as i,U as it,W as rt,Z as C,a as v,ba as at,g as f,q as _}from"./chunk-YL2YTMD7.js";import"./chunk-RQFURXHW.js";var Ut=[0,25,17,9],Yt=[0,25+64,17+80,9+96],E=0,Bt=1,j=2,z=3,Ht=4,Qt=5,jt=7,zt=9,L=10,Gt=11,Xt=12,qt=13,ut=14,Wt=15,K=15;var Zt=17-4,$t=110-4,Jt=105,G=[0,0,8,10,8,16,8,16,8,4,4,2,1,2,1,1],te=[0,0,2,2,2,2,4,4,8,4,4,4,4,2,2,2],ee=[0,0,0,0,0,1,0,1,0,0,2,1,0,0,0,0],mt=[0,0,1,1,2,2,2,2,8,4,4,2,2,2,2,1],V=class{constructor(t,e){this.regs=new Uint8Array(16);this.dma_enabled=!1;this.dliop=0;this.mode=0;this.jmp=!1;this.lms=!1;this.dlarg_lo=0;this.dlarg_hi=0;this.period=0;this.scanaddr=0;this.startaddr=0;this.pfbyte=0;this.ch=0;this.linesleft=0;this.yofs=0;this.isfirstline=!1;this.v=0;this.h=0;this.linebuf=new Uint8Array(48);this.dmaclock=0;this.dmaidx=0;this.output=0;this.dramrefresh=!1;this.in_vscroll=0;this.read=t,this.nmi=e}reset(){this.regs.fill(0),this.regs[ut]=0,this.regs[K]=127,this.regs[Xt]=0,this.regs[qt]=255,this.setReg(E,0),this.h=this.v=0,this.startaddr=this.scanaddr=0,this.dmaclock=0}saveState(){return _(0,{},this)}loadState(t){_(0,this,t),this.setReg(E,t.regs[E])}static stateToLongString(t){let e="";return e+="H: "+v(t.h,3)+" V: "+v(t.v,3)+` `,e+="DLIOp: "+f(t.dliop,2)+" Lines: "+t.yofs+"/"+t.linesleft,e+=" DMA "+(t.dma_enabled?"ON ":"off"),t.dma_enabled&&(e+=" idx "+t.dmaidx+" clk "+f(t.dmaclock)),e+=` `,e+="Addr: "+f(t.scanaddr,4)+` `,e+=y(t.regs,0,16).replace("$00","Regs"),e}setReg(t,e){switch(t){case L:this.regs[L]=255;return;case Wt:this.regs[K]=31;return}this.regs[t]=e}readReg(t){switch(t){case K:return this.regs[t];case Gt:return this.v>>1;default:return 255}}processDLIEntry(){if(this.mode==0)this.linesleft=(this.dliop>>4&7)+1,this.dmaclock=0;else{this.linesleft=G[this.mode],this.period=te[this.mode],this.jmp?(this.regs[j]=this.dlarg_lo,this.regs[z]=this.dlarg_hi,this.mode=this.period=0,this.dliop&64&&(this.linesleft=1,this.dma_enabled=!1),this.dmaclock=0):this.lms&&(this.scanaddr=this.dlarg_lo+(this.dlarg_hi<<8)),this.startaddr=this.scanaddr;let t=this.regs[E]&3,e=this.dliop&16?(this.regs[Ht]&15)>>1:0;this.dliop&16&&t<3&&t++,this.left=Ut[t]+e,this.right=Yt[t]+e;let s=this.regs[Qt]&15;this.dliop&32^this.in_vscroll&&(this.in_vscroll?this.linesleft=s+1:(this.linesleft-=s,this.yofs+=s),this.linesleft&=15,this.in_vscroll^=32)}}nextLine(){this.linesleft>0&&(this.linesleft--,this.yofs++,this.isfirstline=!1,this.mode>=8&&this.linesleft&&(this.scanaddr=this.startaddr))}triggerNMI(t){this.regs[K]=t|31,this.regs[ut]&t&&this.nmi()}getDlistAddr(){return this.regs[j]+(this.regs[z]<<8)}nextInsn(){let t=this.getDlistAddr(),e=this.read(t);return t=t+1&1023|t&~1023,this.regs[j]=t&255,this.regs[z]=t>>8,e}nextScreen(){let t=this.read(this.scanaddr);return this.incScanAddr(),t}incScanAddr(){this.scanaddr=this.scanaddr+1&4095|this.scanaddr&~4095}dlDMAEnabled(){return this.regs[E]&32}isVisibleScanline(){return this.v>=8&&this.v<248}isPlayfieldDMAEnabled(){return this.dma_enabled&&!this.linesleft}isPlayerDMAEnabled(){return this.regs[E]&8}isMissileDMAEnabled(){return this.regs[E]&12}isWSYNC(){return this.regs[L]!=0}clockPulse(){let t=this.isWSYNC();if(!this.isVisibleScanline())this.doVBlank();else{switch(this.h){case 0:this.isMissileDMAEnabled()&&(this.doPlayerMissileDMA(3),t=!0);break;case 1:if(this.isPlayfieldDMAEnabled()){let e=this.nextInsn();this.jmp=(e&~64)==1,this.lms=(e&64)!=0&&(e&15)!=0,this.mode=e&15,this.dliop=e,this.yofs=0,this.isfirstline=!0,t=!0}break;case 2:case 3:case 4:case 5:this.isPlayerDMAEnabled()&&(this.doPlayerMissileDMA(this.h+2),t=!0);break;case 6:case 7:this.isPlayfieldDMAEnabled()&&this.isfirstline&&(this.jmp||this.lms)&&(this.h==6&&(this.dlarg_lo=this.nextInsn()),this.h==7&&(this.dlarg_hi=this.nextInsn()),t=!0);break;case 8:this.isfirstline&&this.processDLIEntry(),this.dliop&128&&this.linesleft==1&&this.triggerNMI(128);break;case 9:break;case 111:this.dma_enabled&&this.nextLine(),++this.v;break}if(this.output=0,this.mode>=2&&this.period){let e=this.h<=Jt;this.dmaclock=this.dmaclock<<1&511,this.dmaclock&1<=8&&this.incScanAddr(),t=e),this.output=this.h>=this.left+3&&this.h<=this.right+2?4:0}}return(this.h$t)&&(this.output=2),this.incHorizCounter(),!t&&this.dramrefresh&&(this.read(0),this.dramrefresh=!1,t=!0),t}incHorizCounter(){switch(this.h){case 25:case 25+4*1:case 25+4*2:case 25+4*3:case 25+4*4:case 25+4*5:case 25+4*6:case 25+4*7:case 25+4*8:this.dramrefresh=!0;break;case 102:this.regs[L]=0;break;case 113:this.h=0;return}++this.h}doVBlank(){this.linesleft=this.mode=this.period=0,this.h==111&&this.v++,this.v==248&&this.h==0&&this.triggerNMI(64),this.v==262&&this.h==112&&(this.v=0),this.v==7&&this.h==113&&(this.dma_enabled=this.dlDMAEnabled()!=0),this.output=2,this.dmaclock=0}doPlayerMissileDMA(t){let e=this.regs[E]&16,s=this.regs[jt]<<8;e?(s&=63488,s|=t<<8,s|=this.v&255):(s&=64512,s|=t<<7,s|=this.v>>1),this.read(s)}readBitmapData(){let t=this.mode;if(t<8){let e=this.ch,s=this.yofs>>ee[this.mode],a=s&7,n=this.regs[zt];(t&14)==6?(e&=63,n&=254):(e&=127,n&=252);let h=(e<<3)+(n<<8);if((t&14)==2){let o=this.regs[Bt],l=t==3&&(e&96)==96;o&4?this.pfbyte=this.read(h+(a^7)):this.pfbyte=this.read(h+a),l&&s<2&&(this.pfbyte=0),!l&&s>7&&(this.pfbyte=0),this.ch&128&&(o&1&&(this.pfbyte=0),o&2&&(this.pfbyte^=255))}else this.pfbyte=this.read(h+a)}else this.pfbyte=this.nextScreen()}shiftout(){if(this.output==4)switch(this.mode){case 2:case 3:case 15:{let t=this.pfbyte>>7&1;return this.pfbyte<<=1,t?8:6}case 6:case 7:{let t=this.pfbyte>>7&1;return this.pfbyte<<=1,t?(this.ch>>6)+4:0}case 9:case 11:case 12:{let t=this.pfbyte>>7&1;return this.pfbyte<<=1,t?4:0}case 4:case 5:{let t=this.pfbyte>>6&3;return this.pfbyte<<=2,this.ch&128?[0,4,5,7][t]:[0,4,5,6][t]}case 8:case 10:case 13:case 14:{let t=this.pfbyte>>6&3;return this.pfbyte<<=2,[0,4,5,6][t]}}return this.output}};var se=0;var ie=8,re=12,gt=13,pt=17,A=18,g=22,ae=23,ne=24,he=25,S=26,w=27,oe=28,bt=29,ce=30,le=31,fe=0,de=4,xe=8,N=12,_t=16,X=31,At=-9,F=[0,1,2,3,7,7,7,7,8,8,8,8,4,5,6,7,0,1,2,3,7,7,7,7,8,8,8,8,4,5,6,7,0,1,6,7,5,5,5,5,8,8,8,8,2,3,4,5,0,1,6,7,5,5,5,5,8,8,8,8,2,3,4,5,4,5,6,7,3,3,3,3,8,8,8,8,0,1,2,3,4,5,6,7,3,3,3,3,8,8,8,8,0,1,2,3,4,5,6,7,3,3,3,3,8,8,8,8,0,1,2,3,4,5,6,7,3,3,3,3,8,8,8,8,0,1,2,3,2,3,4,5,7,7,7,7,8,8,8,8,0,1,6,7,2,3,4,5,7,7,7,7,8,8,8,8,0,1,6,7,2,3,4,5,7,7,7,7,8,8,8,8,0,1,6,7,2,3,4,5,7,7,7,7,8,8,8,8,0,1,6,7,2,3,4,5,7,7,7,7,8,8,8,8,0,1,6,7,2,3,4,5,7,7,7,7,8,8,8,8,0,1,6,7,2,3,4,5,7,7,7,7,8,8,8,8,0,1,6,7,2,3,4,5,7,7,7,7,8,8,8,8,0,1,6,7],ue=[A+0,A+1,A+2,A+3,g+0,g+1,g+2,g+3,S,S,S,S,g+0,g+1,g+2,g+3],U=class{constructor(){this.regs=new Uint8Array(32);this.readregs=new Uint8Array(32);this.shiftregs=new Uint32Array(8);this.count=0;this.an=0;this.rgb=0;this.pmcol=0;this.gtiacol=0;this.gtiacol2=0;this.hbias=At;this.pmDebugMask=-1}reset(){this.regs.fill(0),this.readregs.fill(0),this.readregs[20]=15,this.readregs.fill(15,21),this.count=0}saveState(){return _(0,{},this)}loadState(t){_(0,this,t)}setReg(t,e){switch(t){case A:case A+1:case A+2:case A+3:case g:case g+1:case g+2:case g+3:case S:e&=254;break;case ce:this.readregs.fill(0,0,16);return}this.regs[t]=e}readReg(t){switch(t){case X:return this.readregs[t]&~this.regs[le]}return this.readregs[t]}sync(){this.count=0}setBias(t){this.hbias=At+t}updateGfx(t,e,s){switch(t){case 0:this.regs[bt]&1&&(this.regs[pt]=s);break;case 2:case 3:case 4:case 5:this.regs[bt]&2&&(!(e&1)||!(this.regs[oe]&1<>6){case 0:switch(this.an){case 0:return S;case 4:case 5:case 6:case 7:return g+this.an-4;case 8:return this.regs[ne]&240|this.regs[ae]&15|256}break;case 1:return this.regs[S]&240|this.gtiacol&15|256;case 2:return ue[this.gtiacol];case 3:return this.regs[S]&15|this.gtiacol<<4|256}return 256}anySpriteActive(){return this.shiftregs[0]||this.shiftregs[1]||this.shiftregs[2]||this.shiftregs[3]||this.shiftregs[4]||this.shiftregs[5]||this.shiftregs[6]||this.shiftregs[7]}processPlayerMissile(){if(!this.anySpriteActive()){this.evalTrigger(0),this.evalTrigger(1),this.evalTrigger(2),this.evalTrigger(3),this.evalTrigger(4),this.evalTrigger(5),this.evalTrigger(6),this.evalTrigger(7),this.pmcol=-1;return}if(this.an==2){this.shiftObject(0),this.shiftObject(1),this.shiftObject(2),this.shiftObject(3),this.shiftObject(4),this.shiftObject(5),this.shiftObject(6),this.shiftObject(7),this.pmcol=-1;return}let t=(this.regs[w]&15)<<4,e=F[(this.an&7)+8+t],s=this.an-4,a=-1,n=0;for(let h=0;h<4;h++)if(this.shiftObject(h)){s>=0&&(this.readregs[de+h]|=1<=0&&(this.readregs[fe+h]|=1<=0?this.getObjectColor(a):-1}shiftObject(t){let e=(this.shiftregs[t]&2147483648)!=0;return this.shiftregs[t]<<=1,this.evalTrigger(t),e}getObjectColor(t){return this.regs[w]&16&&t>=4?this.regs[he]:this.regs[A+(t&3)]}evalTrigger(t){this.regs[se+t]+this.hbias==this.count&&this.triggerObject(t)}triggerObject(t){let e,s;if(!!(this.pmDebugMask&1<>a&3,s=(this.regs[pt]>>a&3)<<6}e&1?s=yt(s):s<<=8,e==3?s=yt(s):s<<=16,this.shiftregs[t]|=s}}clockPulse1(){this.processPlayerMissile(),this.clockPulse2(),this.count++}clockPulse2(){var t;if(this.pmcol>=0)t=this.pmcol;else{let e=this.getPlayfieldColor();t=e&256?e&255:this.regs[e]}this.rgb=Et[t],this.gtiacol2=this.gtiacol2<<1|this.an>>3}clockPulse4(){this.gtiacol=this.gtiacol2&15}static stateToLongString(t){let e="";return e+=`X: ${v(t.count,3)} ANTIC: ${f(t.an,1)} PM: ${f(t.pmcol,3)} @@ -7,4 +7,4 @@ import{a as xt}from"./chunk-7TOHRG6S.js";import{B as ft,I as dt,g as nt,k as ht, `,e+=y(t.readregs,0,32),e}};function yt(r){return r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,r|r<<1}var Et=new Uint32Array(256);for(k=0;k<256;k++)Et[k]=at(k);var k;var c=0;var me=2;var St=4;var Ot=6;var p=8,ge=9,pe=10,be=11,_e=13,q=14,R=15;var Ae=8,ye=9,Ee=10,Se=13,P=14,Y=15;var Rt=128,It=64,Oe=32,Tt=16,Pt=8;var Re=1,Dt=28,Ie=114;var Mt=511,vt=131071,u=0,m=1,b=2,d=3,O=114,Te=15;var Pe=8;var W,B;function De(){W=new Uint8Array(511),B=new Uint8Array(16385);let r=511;for(let t=0;t<511;t++)r=(((r>>5^r)&1)<<8)+(r>>1),W[t]=r;r=131071;for(let t=0;t<16385;t++)r=(((r>>5^r)&255)<<9)+(r>>8),B[t]=r>>1}var H=class{constructor(t,e){this.irq=t;this.antic_xpos=e;this.regs=new Uint8Array(16);this.readregs=new Uint8Array(16);this.divnirq=new Uint32Array(4);this.divnmax=new Uint32Array(4);this.pot_inputs=new Uint8Array(8);this.basemult=0;this.pot_scanline=0;this.random_scanline_counter=0;this.kbcode=0;this.DELAYED_SERIN_IRQ=0;this.DELAYED_SEROUT_IRQ=0;this.DELAYED_XMTDONE_IRQ=0;this.init()}saveState(){return _(0,{},this)}loadState(t){_(0,this,t)}init(){this.readregs.fill(255),this.readregs[Y]=239,this.basemult=Dt,this.pot_inputs.fill(128),De()}read(t){let e=this.readregs[t];switch(t&=15,t){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:return e=this.pot_inputs[t],e>3;s&=7,e=(B[a]>>s)+(B[a+1]<<8-s)}}break}return e&255}write(t,e){switch(t&=15,this.regs[t]=e,t){case p:e&Re?this.basemult=Ie:this.basemult=Dt,this.update_counter(1<=3?(this.readregs[P]|=8,this.DELAYED_XMTDONE_IRQ=2*this.DELAYED_SEROUT_IRQ-2):(this.DELAYED_SEROUT_IRQ=0,this.DELAYED_XMTDONE_IRQ=0));break;case ge:this.divnirq[u]=this.divnmax[u],this.divnirq[m]=this.divnmax[m],this.divnirq[b]=this.divnmax[b],this.divnirq[d]=this.divnmax[d];break;case R:e&4&&(this.pot_scanline=228),(e&3)==0&&(this.DELAYED_SERIN_IRQ=0,this.DELAYED_SEROUT_IRQ=0,this.DELAYED_XMTDONE_IRQ=0);break}this.snd_update(t)}update_counter(t){t&1<0&&--this.DELAYED_SERIN_IRQ==0&&(this.readregs[Se]=this.SIO_GetByte(),this.generateIRQ(32)),this.DELAYED_SEROUT_IRQ>0&&--this.DELAYED_SEROUT_IRQ==0&&this.generateIRQ(16),this.DELAYED_XMTDONE_IRQ>0&&--this.DELAYED_XMTDONE_IRQ==0&&this.generateIRQ(8),this.advanceIRQTimer(u,1),this.advanceIRQTimer(m,2),this.advanceIRQTimer(d,4))}advanceIRQTimer(t,e){(this.divnirq[t]-=O)<0&&(this.divnirq[t]+=this.divnmax[t],this.generateIRQ(e))}generateIRQ(t){this.regs[q]&t&&(this.irq(),this.readregs[P]&=~t)}static stateToLongString(t){let e="";return e+=`Write Registers: `,e+=y(t.regs,0,16),e+=`Read Registers: `,e+=y(t.readregs,0,16),e}CASSETTE_IOLineStatus(){return 0}siocheck(){return((this.regs[c+b]==40||this.regs[c+b]==16||this.regs[c+b]==8||this.regs[c+b]==10)&&this.regs[c+d]==0||(this.regs[R]&120)==40)&&(this.regs[p]&40)==40}SIO_PutByte(t){console.log("SIO put byte",t)}SIO_GetByte(){return 0}};var Me=[i.VK_L,i.VK_J,i.VK_SEMICOLON,i.VK_F4,i.VK_F5,i.VK_K,i.VK_BACK_SLASH,i.VK_TILDE,i.VK_O,null,i.VK_P,i.VK_U,i.VK_ENTER,i.VK_I,i.VK_MINUS2,i.VK_EQUALS2,i.VK_V,i.VK_F7,i.VK_C,i.VK_F6,i.VK_F4,i.VK_B,i.VK_X,i.VK_Z,i.VK_4,null,i.VK_3,i.VK_6,i.VK_ESCAPE,i.VK_5,i.VK_2,i.VK_1,i.VK_COMMA,i.VK_SPACE,i.VK_PERIOD,i.VK_N,null,i.VK_M,i.VK_SLASH,null,i.VK_R,null,i.VK_E,i.VK_Y,i.VK_TAB,i.VK_T,i.VK_W,i.VK_Q,i.VK_9,null,i.VK_0,i.VK_7,i.VK_BACK_SPACE,i.VK_8,null,null,i.VK_F,i.VK_H,i.VK_D,null,i.VK_CAPS_LOCK,i.VK_G,i.VK_S,i.VK_A],ve=rt([[i.UP,0,1],[i.DOWN,0,2],[i.LEFT,0,4],[i.RIGHT,0,8],[{c:16,n:"Shift",plyr:0,button:0},2,1],[i.VK_F1,3,1],[i.VK_F2,3,2],[i.VK_F3,3,4]]),Q=class extends ot{constructor(){super();this.cpuFrequency=1789773;this.numTotalScanlines=262;this.cpuCyclesPerLine=114;this.canvasWidth=336;this.numVisibleScanlines=224;this.aspectRatio=this.canvasWidth/this.numVisibleScanlines*.857;this.firstVisibleScanline=16;this.firstVisibleClock=(44-6)*2;this.defaultROMSize=32768;this.overscan=!0;this.audioOversample=2;this.sampleRate=this.numTotalScanlines*60*this.audioOversample;this.run_address=-1;this.inputs=new Uint8Array(4);this.linergb=new Uint32Array(this.canvasWidth);this.lastdmabyte=0;this.keycode=0;this.cart_80=!1;this.cart_a0=!1;this.xexdata=null;this.keyboard_active=!0;this.d500=new Uint8Array(256);this.cpu=new ct,this.ram=new Uint8Array(65536),this.bios=new Uint8Array(10240),this.bus=this.newBus(),this.connectCPUMemoryBus(this.bus),this.antic=new V(this.readDMA.bind(this),this.antic_nmi.bind(this)),this.gtia=new U,this.irq_pokey=new H(this.pokey_irq.bind(this),()=>this.antic.h),this.audio_pokey=nt(1),this.audioadapter=new ht(this.audio_pokey.pokey1,this.audioOversample,this.sampleRate),this.handler=it(this.inputs,ve,this.getKeyboardFunction(),!0)}newBus(){return{read:C([[0,32767,65535,t=>this.ram[t]],[32768,40959,65535,t=>this.cart_80?this.rom[t-32768]:this.ram[t]],[40960,49151,65535,t=>this.cart_a0?this.rom[t-32768]:this.ram[t]],[53248,53503,31,t=>this.gtia.readReg(t)],[53760,54015,15,t=>this.readPokey(t)],[54016,54271,15,t=>this.readPIA(t)],[54272,54527,15,t=>this.antic.readReg(t)],[54528,54783,255,t=>this.d500[t]],[55296,65535,65535,t=>this.bios[t-55296]]]),write:C([[0,49146,65535,(t,e)=>{this.ram[t]=e}],[49147,49151,65535,(t,e)=>{this.ram[t]=e,this.initCartA()}],[53248,53503,31,(t,e)=>{this.gtia.setReg(t,e)}],[53760,54015,15,(t,e)=>{this.writePokey(t,e)}],[54272,54527,15,(t,e)=>{this.antic.setReg(t,e)}],[54528,54783,255,(t,e)=>{this.writeMapper(t,e)}]])}}loadBIOS(t){this.bios.set(t)}reset(){super.reset(),this.antic.reset(),this.gtia.reset(),this.keycode=0}read(t){return this.bus.read(t)}readDMA(t){let e=this.bus.read(t);return this.probe.logDMARead(t,e),this.lastdmabyte=e,e}readConst(t){return t<53248||t>=54528?this.bus.read(t):255}write(t,e){this.bus.write(t,e)}readPokey(t){switch(t&15){case 9:return this.keycode&255;case 15:return~this.keycode>>6&4|~this.keycode>>3&8|18;default:return this.irq_pokey.read(t)}}readPIA(t){if(t==0||t==1)return~this.inputs[t]}writePokey(t,e){this.audio_pokey.pokey1.setRegister(t,e),this.irq_pokey.write(t,e)}startScanline(){this.gtia.sync();for(let t=0;t<4;t++)this.gtia.readregs[_t+t]=~this.inputs[2]>>t&1;this.gtia.readregs[X]=~this.inputs[3]&7,this.audio&&this.audioadapter.generate(this.audio),this.irq_pokey.advanceScanline()}drawScanline(){let t=this.antic.v-this.firstVisibleScanline;t>=0&&t{this.gtia.clockPulse1(),this.linergb[t++]=this.gtia.rgb},s=()=>{this.gtia.clockPulse2(),this.linergb[t++]=this.gtia.rgb};this.gtia.clockPulse4(),this.antic.dliop&16&&this.antic.regs[4]&1?(t+=2,this.gtia.setBias(-1)):this.gtia.setBias(0);let a=mt[this.antic.mode],n=this.antic.h&1;return(a<8||n)&&(this.gtia.an=this.antic.shiftout()),e(),a==1&&(this.gtia.an=this.antic.shiftout()),s(),a<=2&&(this.gtia.an=this.antic.shiftout()),e(),a==1&&(this.gtia.an=this.antic.shiftout()),s(),1}loadState(t){this.loadControlsState(t),this.cpu.loadState(t.c),this.ram.set(t.ram),this.antic.loadState(t.antic),this.gtia.loadState(t.gtia),this.irq_pokey.loadState(t.pokey),this.lastdmabyte=t.lastdmabyte,this.cart_80=t.cart_80,this.cart_a0=t.cart_a0}saveState(){return{c:this.cpu.saveState(),ram:this.ram.slice(0),antic:this.antic.saveState(),gtia:this.gtia.saveState(),pokey:this.irq_pokey.saveState(),inputs:this.inputs.slice(0),lastdmabyte:this.lastdmabyte,keycode:this.keycode,cart_80:this.cart_80,cart_a0:this.cart_a0}}loadControlsState(t){this.inputs.set(t.inputs),this.keycode=t.keycode}saveControlsState(){return{inputs:this.inputs.slice(0),keycode:this.keycode}}getRasterScanline(){return this.antic.v}getRasterLineClock(){return this.antic.h}getDebugCategories(){return["CPU","Stack","ANTIC","GTIA","POKEY"]}getDebugInfo(t,e){switch(t){case"ANTIC":return V.stateToLongString(e.antic);case"GTIA":return U.stateToLongString(e.gtia);case"POKEY":return H.stateToLongString(e.pokey)}}getKeyboardFunction(){return(t,e,s,a)=>{if(!this.keyboard_active)return!1;if(a&(T.KeyDown|T.KeyUp)){var n=Me;if(e==i.VK_F9.c)return this.irq_pokey.generateIRQ(128),!0;for(var h=0;h>8}if(e>t.length)throw new Error("Bad .XEX file format")}n>=0&&(s[a++]=169,s[a++]=160,s[a++]=141,s[a++]=255,s[a++]=213,s[a++]=76,s[a++]=n&255,s[a++]=n>>8,this.ram[10]=0,this.ram[11]=213,this.run_address=54528)}initCartA(){this.cpu.getPC()==61823&&this.xexdata&&this.loadXEX(this.xexdata)}setPaddleInput(t,e){this.irq_pokey.pot_inputs[t]=255-e}getDebugDisplayList(){let t=this.antic.getDlistAddr(),e=()=>{let n=this.read(t);return t=t+1&1023|t&~1023,n},s=[],a=0;for(let n=0;n<256&&a<240;n++){let h=t,o=e(),l=o&15,x="",D=!1,M;if(l==0)M=(o>>4&7)+1,x+=" blank="+M;else{M=G[l],x+=" mode="+f(l),x+=" lines="+M,D=(o&~64)==1;let st=(o&64)!=0&&(o&15)!=0;if(o&16&&(x+=" HSCROL"),o&32&&(x+=" VSCROL"),o&128&&(x+=" DLI"),D&&o&64?x+=" JVB":D?x+=" JMP":st&&(x+=" LMS"),D||st){let Nt=e(),Ft=e();x+=" $"+f(Ft)+""+f(Nt)}}if(s.push("$"+f(h)+" y="+a+" "+x),D)break;a+=M}return s}},Z=class extends Q{newBus(){return{read:C([[0,16383,65535,t=>this.ram[t]],[16384,49151,65535,t=>this.rom?this.rom[t-16384]:0],[49152,53247,31,t=>this.gtia.readReg(t)],[54272,54527,15,t=>this.antic.readReg(t)],[59392,61439,15,t=>this.readPokey(t)],[63488,65535,2047,t=>this.bios[t]]]),write:C([[0,16383,65535,(t,e)=>{this.ram[t]=e}],[49152,53247,31,(t,e)=>{this.gtia.setReg(t,e)}],[54272,54527,15,(t,e)=>{this.antic.setReg(t,e)}],[59392,61439,15,(t,e)=>{this.writePokey(t,e)}]])}}};var $=[{id:"hello.dasm",name:"Hello World (ASM)"},{id:"hellopm.dasm",name:"Hello Sprites (ASM)"},{id:"helloconio.c",name:"Text Mode (C)"},{id:"siegegame.c",name:"Siege Game (C)"},{id:"hellodlist.c",name:"Display List (C)"}],Ct=$.concat([{id:"testmusic.c",name:"POKEY Music (C)"},{id:"sieve.bas",name:"Benchmark (FastBasic)"},{id:"pmtest.bas",name:"Sprites Test (FastBasic)"},{id:"dli.bas",name:"DLI Test (FastBasic)"},{id:"joyas.bas",name:"Match-3 Game (FastBasic)"}]),kt={main:[{name:"RAM",start:0,size:49152,type:"ram"},{name:"Left Cartridge ROM",start:40960,size:8192,type:"rom"},{name:"GTIA",start:53248,size:32,type:"io"},{name:"POKEY",start:53760,size:16,type:"io"},{name:"PIA",start:54016,size:4,type:"io"},{name:"ANTIC",start:54272,size:16,type:"io"},{name:"Cartridge Control Line",start:54784,size:256,type:"io"},{name:"ROM",start:55296,size:2048,type:"rom"},{name:"Character Set",start:57344,size:1024,type:"rom"},{name:"ROM",start:58368,size:7168,type:"rom"}]};function Lt(r){return r.endsWith(".bas")||r.endsWith(".fb")||r.endsWith(".fbi")?"fastbasic":lt(r)}var J=class extends dt{constructor(){super(...arguments);this.getToolForFilename=Lt;this.showHelp=wt;this.getROMExtension=Ce;this.biosPath="res/altirra/kernel.rom"}newMachine(){return new Q}getPresets(){return Ct}getDefaultExtension(){return".c"}readAddress(t){return this.machine.readConst(t)}getMemoryMap(){return kt}async start(){let t=await this.loadKernel();await super.start(),this.machine.loadBIOS(t)}async loadKernel(){var t=await fetch(this.biosPath);if(t.status==200||t.size){var e=await t.arrayBuffer();return new Uint8Array(e)}else throw new Error("could not load BIOS file")}getDebugTree(){let t=super.getDebugTree();return t.display_list=this.machine.getDebugDisplayList(),t}},Kt=class extends J{constructor(){super(...arguments);this.biosPath="res/altirra/superkernel.rom"}getPresets(){return $}newMachine(){return new Z}},tt=class extends xt{constructor(){super(...arguments);this.getToolForFilename=Lt;this.getOpcodeMetadata=ft;this.showHelp=wt}getPresets(){return $}getDefaultExtension(){return".asm"}},et=class extends tt{constructor(){super(...arguments);this.getMemoryMap=function(){return kt}}getPresets(){return Ct}loadROM(t,e){this.started?(this.loadROMFile(e),this.loadRegion(":cartleft:cart:rom",e)):this.startModule(this.mainElement,{jsfile:"mame8bitws.js",biosfile:"a800xl.zip",cfgfile:"a800xl.cfg",driver:"a800xl",width:336*2,height:225*2,romfn:"/emulator/cart.rom",romdata:new Uint8Array(e),romsize:8192,preInit:function(s){}})}start(){}},Vt=class extends tt{constructor(){super(...arguments);this.getMemoryMap=function(){return{main:[{name:"RAM",start:0,size:16384,type:"ram"},{name:"Cartridge ROM",start:16384,size:32768,type:"rom"},{name:"GTIA",start:49152,size:32,type:"io"},{name:"ANTIC",start:54272,size:16,type:"io"},{name:"POKEY",start:59392,size:16,type:"io"},{name:"ATARI Character Set",start:63488,size:1024,type:"rom"},{name:"ROM",start:64512,size:1024,type:"rom"}]}}}loadROM(t,e){this.started?(this.loadROMFile(e),this.loadRegion(":cartleft:cart:rom",e)):this.startModule(this.mainElement,{jsfile:"mame8bitws.js",biosfile:"a5200/5200.rom",cfgfile:"a5200.cfg",driver:"a5200",width:336*2,height:225*2,romfn:"/emulator/cart.rom",romdata:new Uint8Array(e),romsize:32768,preInit:function(s){}})}start(){}};function Ce(r){return r==null?".bin":r[0]==255&&r[1]==255?".xex":".rom"}function wt(){return"https://8bitworkshop.com/docs/platforms/atari8/"}I["atari8-800.xlmame"]=et;I["atari8-800xl.mame"]=et;I["atari8-5200.mame"]=Vt;I["atari8-800"]=J;I["atari8-5200"]=Kt; -//# sourceMappingURL=atari8-AI5453LS.js.map +//# sourceMappingURL=atari8-YJPSBKKM.js.map diff --git a/gen/atari8-AI5453LS.js.map b/gen/atari8-YJPSBKKM.js.map similarity index 100% rename from gen/atari8-AI5453LS.js.map rename to gen/atari8-YJPSBKKM.js.map diff --git a/gen/basic-LB3JIOIE.js b/gen/basic-35NRKUG4.js similarity index 98% rename from gen/basic-LB3JIOIE.js rename to gen/basic-35NRKUG4.js index aad79770..dc14468a 100644 --- a/gen/basic-LB3JIOIE.js +++ b/gen/basic-35NRKUG4.js @@ -1,4 +1,4 @@ -import{b as v}from"./chunk-3XE5YOCV.js";import{a as d,o as S}from"./chunk-UC5KI5RU.js";import"./chunk-SXEVG2WS.js";import"./chunk-5SHCNQ2O.js";import"./chunk-RDEVPY4D.js";import"./chunk-4UNLDFGJ.js";import{A as c,J as b,S as g,T as f,a as p}from"./chunk-47V4PEOO.js";import"./chunk-5XVCUSSZ.js";function O(o){return o.value!=null}function E(o){return o.name!=null}function N(o){return o.op!=null&&o.left!=null&&o.right!=null}function I(o){return o.op!=null&&o.expr!=null}var y=class{randomize(){this.seed(Math.random()*2147483647,Math.random()*2147483647,Math.random()*2147483647,Math.random()*2147483647)}constructor(){(()=>{var r,e,i,n;this.seed=function(s,a,u,h){r=s,e=a,i=u,n=h},this.seedfloat=function(s){this.seed(s,s*4294,s*429496,s*4294967296),this.next(),this.next(),this.next()},this.next=function(){r>>>=0,e>>>=0,i>>>=0,n>>>=0;var s=r+e|0;return r=e^e>>>9,e=i+(i<<3)|0,i=i<<21|i>>>11,n=n+1|0,s=s+n|0,i=i+s|0,(s>>>0)/4294967296}})(),this.seedfloat(-1)}},L=1024*1024,l=class{constructor(){this.margin=80;this.running=!1;this.exited=!0;this.trace=!1}load(t){let r=null,e=0;if(this.pc2label!=null){let s=this.curpc;for(;s>0&&(r=this.pc2label.get(s))==null;)s--;e=this.curpc-s,console.log("oldpc=",this.curpc,"restart @ label",r,"+",e)}this.program=t,this.opts=t.opts,this.opts.maxArrayElements||(this.opts.maxArrayElements=L),this.allstmts=t.stmts,this.label2pc=t.labels,this.label2dataptr={},this.pc2label=new Map,this.datums=[],this.subroutines={},this.builtins=this.getBuiltinFunctions();for(var i in t.labels){var n=t.labels[i];this.pc2label.set(n,i)}return this.allstmts.forEach((s,a)=>{this.curpc=a+1,this.compileStatement(s),s.command=="DATA"&&(this.label2dataptr[s.$loc.label]=this.datums.length,s.datums.forEach(u=>{this.curpc=s.$loc.offset,this.datums.push(u)}))}),this.label2pc[r]!=null?(this.curpc=this.label2pc[r]+e,!0):(this.curpc=0,!1)}reset(){this.curpc=0,this.dataptr=0,this.clearVars(),this.returnStack=[],this.column=0,this.running=!0,this.exited=!1}clearVars(){this.globals=this.vars={},this.arrays={},this.defs={},this.forLoops={},this.forLoopStack=[],this.whileLoops=[],this.rng=new y,this.opts&&this.opts.staticArrays&&this.allstmts.filter(t=>t.command=="DIM").forEach(t=>{t.args.forEach(r=>this.compileJS(this._DIM(r))())})}saveState(){return $.extend(!0,{},this)}loadState(t){$.extend(!0,this,t)}getBuiltinFunctions(){var t=this.program&&this.opts.validFunctions;t||(t=Object.getOwnPropertyNames(l.prototype).filter(i=>/^[A-Z]{3,}[$]?$/.test(i)));var r={};for(var e of t)this.supportsFunction(e)&&(r[e]=this[e].bind(this));return r}supportsFunction(t){return typeof this[t]=="function"}runtimeError(t){throw this.curpc--,new g(t,this.getCurrentSourceLocation())}dialectError(t){this.runtimeError(`I can't ${t} in this dialect of BASIC.`)}getLineForPC(t){var r=this.allstmts[t];return r&&r.$loc&&r.$loc.line}getLabelForPC(t){var r=this.allstmts[t];return r&&r.$loc&&r.$loc.label}getCurrentSourceLocation(){var t=this.getStatement();return t&&t.$loc}getCurrentLabel(){var t=this.getCurrentSourceLocation();return t&&t.label}getStatement(){return this.allstmts[this.curpc]}step(){if(!this.running)return!1;var t=this.getStatement();return t?(this.trace&&console.log(this.curpc,t,this.vars,Object.keys(this.arrays)),this.curpc++,this.executeStatement(t),this.running):(this.running=!1,this.exited=!0,!1)}compileStatement(t){if(t.$run==null)try{var r=this["do__"+t.command];r==null&&this.runtimeError(`I don't know how to "${t.command}".`);var e=r.bind(this)(t);this.trace&&console.log(e),t.$run=this.compileJS(e)}catch(i){throw e&&console.log(e),i}}compileJS(t){return new Function(t).bind(this)}executeStatement(t){this.compileStatement(t),t.$run()}skipToEOL(){do this.curpc++;while(this.curpc=0?this.curpc=r:this.runtimeError(`I tried to go to the label "${t}" but couldn't find it.`)}newLocalScope(){this.vars=Object.create(this.vars)}popLocalScope(){this.vars!==this.globals&&(this.vars=Object.getPrototypeOf(this.vars))}gosubLabel(t){this.returnStack.length>32767&&this.runtimeError("I did too many GOSUBs without a RETURN."),this.returnStack.push(this.curpc),this.gotoLabel(t)}returnFromGosub(){this.returnStack.length==0&&this.runtimeError("I tried to RETURN, but there wasn't a corresponding GOSUB.");var t=this.returnStack.pop();this.curpc=t,this.popLocalScope()}popReturnStack(){this.returnStack.length==0&&this.runtimeError("I tried to POP, but there wasn't a corresponding GOSUB."),this.returnStack.pop()}valueToString(t,r){var e;if(typeof t=="number"){var i=this.float2str(t,this.opts.printZoneLength-4);return r?i.startsWith("-")?`${i} `:` ${i} `:i}else if(t==` +import{b as v}from"./chunk-3XE5YOCV.js";import{a as d,o as S}from"./chunk-FULWX6T7.js";import"./chunk-SDBJC2RS.js";import"./chunk-XMPGMPQ4.js";import"./chunk-LBWPHUUP.js";import"./chunk-GKVIY6GD.js";import{A as c,H as b,Q as g,R as f,a as p}from"./chunk-YL2YTMD7.js";import"./chunk-RQFURXHW.js";function O(o){return o.value!=null}function E(o){return o.name!=null}function N(o){return o.op!=null&&o.left!=null&&o.right!=null}function I(o){return o.op!=null&&o.expr!=null}var y=class{randomize(){this.seed(Math.random()*2147483647,Math.random()*2147483647,Math.random()*2147483647,Math.random()*2147483647)}constructor(){(()=>{var r,e,i,n;this.seed=function(s,a,u,h){r=s,e=a,i=u,n=h},this.seedfloat=function(s){this.seed(s,s*4294,s*429496,s*4294967296),this.next(),this.next(),this.next()},this.next=function(){r>>>=0,e>>>=0,i>>>=0,n>>>=0;var s=r+e|0;return r=e^e>>>9,e=i+(i<<3)|0,i=i<<21|i>>>11,n=n+1|0,s=s+n|0,i=i+s|0,(s>>>0)/4294967296}})(),this.seedfloat(-1)}},L=1024*1024,l=class{constructor(){this.margin=80;this.running=!1;this.exited=!0;this.trace=!1}load(t){let r=null,e=0;if(this.pc2label!=null){let s=this.curpc;for(;s>0&&(r=this.pc2label.get(s))==null;)s--;e=this.curpc-s,console.log("oldpc=",this.curpc,"restart @ label",r,"+",e)}this.program=t,this.opts=t.opts,this.opts.maxArrayElements||(this.opts.maxArrayElements=L),this.allstmts=t.stmts,this.label2pc=t.labels,this.label2dataptr={},this.pc2label=new Map,this.datums=[],this.subroutines={},this.builtins=this.getBuiltinFunctions();for(var i in t.labels){var n=t.labels[i];this.pc2label.set(n,i)}return this.allstmts.forEach((s,a)=>{this.curpc=a+1,this.compileStatement(s),s.command=="DATA"&&(this.label2dataptr[s.$loc.label]=this.datums.length,s.datums.forEach(u=>{this.curpc=s.$loc.offset,this.datums.push(u)}))}),this.label2pc[r]!=null?(this.curpc=this.label2pc[r]+e,!0):(this.curpc=0,!1)}reset(){this.curpc=0,this.dataptr=0,this.clearVars(),this.returnStack=[],this.column=0,this.running=!0,this.exited=!1}clearVars(){this.globals=this.vars={},this.arrays={},this.defs={},this.forLoops={},this.forLoopStack=[],this.whileLoops=[],this.rng=new y,this.opts&&this.opts.staticArrays&&this.allstmts.filter(t=>t.command=="DIM").forEach(t=>{t.args.forEach(r=>this.compileJS(this._DIM(r))())})}saveState(){return $.extend(!0,{},this)}loadState(t){$.extend(!0,this,t)}getBuiltinFunctions(){var t=this.program&&this.opts.validFunctions;t||(t=Object.getOwnPropertyNames(l.prototype).filter(i=>/^[A-Z]{3,}[$]?$/.test(i)));var r={};for(var e of t)this.supportsFunction(e)&&(r[e]=this[e].bind(this));return r}supportsFunction(t){return typeof this[t]=="function"}runtimeError(t){throw this.curpc--,new g(t,this.getCurrentSourceLocation())}dialectError(t){this.runtimeError(`I can't ${t} in this dialect of BASIC.`)}getLineForPC(t){var r=this.allstmts[t];return r&&r.$loc&&r.$loc.line}getLabelForPC(t){var r=this.allstmts[t];return r&&r.$loc&&r.$loc.label}getCurrentSourceLocation(){var t=this.getStatement();return t&&t.$loc}getCurrentLabel(){var t=this.getCurrentSourceLocation();return t&&t.label}getStatement(){return this.allstmts[this.curpc]}step(){if(!this.running)return!1;var t=this.getStatement();return t?(this.trace&&console.log(this.curpc,t,this.vars,Object.keys(this.arrays)),this.curpc++,this.executeStatement(t),this.running):(this.running=!1,this.exited=!0,!1)}compileStatement(t){if(t.$run==null)try{var r=this["do__"+t.command];r==null&&this.runtimeError(`I don't know how to "${t.command}".`);var e=r.bind(this)(t);this.trace&&console.log(e),t.$run=this.compileJS(e)}catch(i){throw e&&console.log(e),i}}compileJS(t){return new Function(t).bind(this)}executeStatement(t){this.compileStatement(t),t.$run()}skipToEOL(){do this.curpc++;while(this.curpc=0?this.curpc=r:this.runtimeError(`I tried to go to the label "${t}" but couldn't find it.`)}newLocalScope(){this.vars=Object.create(this.vars)}popLocalScope(){this.vars!==this.globals&&(this.vars=Object.getPrototypeOf(this.vars))}gosubLabel(t){this.returnStack.length>32767&&this.runtimeError("I did too many GOSUBs without a RETURN."),this.returnStack.push(this.curpc),this.gotoLabel(t)}returnFromGosub(){this.returnStack.length==0&&this.runtimeError("I tried to RETURN, but there wasn't a corresponding GOSUB.");var t=this.returnStack.pop();this.curpc=t,this.popLocalScope()}popReturnStack(){this.returnStack.length==0&&this.runtimeError("I tried to POP, but there wasn't a corresponding GOSUB."),this.returnStack.pop()}valueToString(t,r){var e;if(typeof t=="number"){var i=this.float2str(t,this.opts.printZoneLength-4);return r?i.startsWith("-")?`${i} `:` ${i} `:i}else if(t==` `)this.column=0,e=t;else if(t==" "){var n=this.opts.printZoneLength,s=Math.floor(this.column/n),a=(s+1)*this.opts.printZoneLength;a+n>this.margin?(this.column=0,e=` `):e=this.TAB(a)}else e=`${t}`;return e}float2str(t,r){var e=t.toString().toUpperCase();if(r>0){for(var i=r;e.length>r;)e=t.toPrecision(i--);e.startsWith("0.")?e=e.substr(1):e.startsWith("-0.")&&(e="-"+e.substr(2))}return e}printExpr(t){var r=this.valueToString(t,this.opts.numericPadding);this.column+=r.length,this.print(r)}print(t){console.log(t)}async input(t,r){return{line:"",vals:[]}}resume(){}expr2js(t,r){if(r||(r={}),O(t))return JSON.stringify(t.value);if(E(t)){if(!t.args&&r.locals&&r.locals.indexOf(t.name)>=0)return t.name;{r.isconst&&this.runtimeError("I expected a constant value here.");var e="",i=JSON.stringify(t.name);let u=t.args?t.args.map(h=>this.expr2js(h,r)).join(", "):[];return t.name.startsWith("FN")?e+=`this.getDef(${i})(${u})`:this.builtins[t.name]?(this.checkFuncArgs(t,this.builtins[t.name]),e+=`this.builtins.${t.name}(${u})`):t.args?this.opts.arraysContainChars&&t.name.endsWith("$")?e+=`this.getStringSlice(this.vars.${t.name}, ${u})`:e+=`this.arrayGet(${i}, ${u})`:e+=`this.vars.${t.name}`,r.novalid?e:`this.checkValue(${e}, ${i})`}}else if(N(t)){var n=this.expr2js(t.left,r),s=this.expr2js(t.right,r);return`this.${t.op}(${n}, ${s})`}else if(I(t)){var a=this.expr2js(t.expr,r);return`this.${t.op}(${a})`}}assign2js(t,r){r||(r={});var e="";return(t.name.startsWith("FN")||this.builtins[t.name])&&this.runtimeError("I can't call a function here."),t.args?this.opts.arraysContainChars&&t.name.endsWith("$")?this.runtimeError("I can't set array slices via this command yet."):e+=this.array2js(t,r):e=`this.globals.${t.name}`,e}array2js(t,r){var e=JSON.stringify(t.name),i=t.args||[];return this.expr2js(t,{novalid:!0})+`;this.getArray(${e}, ${i.length})`+i.map(n=>"[this.ROUND("+this.expr2js(n,r)+")]").join("")}checkFuncArgs(t,r){var e=t.args?t.args.length:0;t.name=="RND"&&e==0||t.name=="MID$"&&e==2||t.name=="INSTR"&&e==2||r.length!=e&&this.runtimeError(`I expected ${r.length} arguments for the ${t.name} function, but I got ${e}.`)}startForLoop(t,r,e,i,n){var s=this.curpc-1,a=this.pc2label.get(s);i||(i=1),this.vars[t]=r,this.trace&&console.log(`FOR ${t} = ${r} TO ${e} STEP ${i}`);var u=()=>i>=0?this.vars[t]>e:this.vars[t]h==t)),this.forLoopStack.push(t),this.forLoops[t]={$next:h=>{h&&t!=h&&this.runtimeError(`I executed NEXT "${h}", but the last FOR was for "${t}".`),this.vars[t]+=i;var m=u();m?(this.forLoopStack.pop(),delete this.forLoops[t]):this.curpc=(a!=null&&this.label2pc[a]||s)+1,this.trace&&console.log(`NEXT ${t}: ${this.vars[t]} TO ${e} STEP ${i} DONE=${m}`)}}}nextForLoop(t){var r=this.forLoops[t||this.opts.optionalNextVar&&this.forLoopStack[this.forLoopStack.length-1]];r||this.runtimeError("I couldn't find a matching FOR for this NEXT."),r.$next(t)}whileLoop(t){t?this.whileLoops.push(this.curpc-1):this.skipToAfterWend()}nextWhileLoop(){var t=this.whileLoops.pop();t==null?this.runtimeError("I couldn't find a matching WHILE for this WEND."):this.curpc=t}assign(t,r,e){return e&&t.endsWith("$")?this.checkValue(this.convert(t,r),t):t.endsWith("$")?this.convertToString(r,t):this.convertToNumber(r,t)}convert(t,r){return t.endsWith("$")?r==null?"":r.toString():typeof r=="number"?r:parseFloat(r+"")}convertToString(t,r){if(typeof t!="string")this.runtimeError(`I can't convert ${t} to a string.`);else return t}convertToNumber(t,r){if(typeof t!="number")this.runtimeError(`I can't convert ${t} to a number.`);else return this.checkNum(t)}dimArray(t,...r){if(r=r.map(Math.round),this.arrays[t]!=null){if(this.opts.staticArrays)return;this.runtimeError(`I already dimensioned this array (${t}) earlier.`)}var e=this.getTotalArrayLength(r);e>this.opts.maxArrayElements&&this.runtimeError("I can't create an array with this many elements.");var i=t.endsWith("$"),n=i?Array:Float64Array;if(r.length==1)this.arrays[t]=new n(r[0]+1);else if(r.length==2){this.arrays[t]=new Array(r[0]+1);for(var s=0;s=i.length&&this.runtimeError(`I tried to lookup ${t}(${r}) but it exceeded the dimensions of the array.`),i=i[r[n]]}return c(i)&&this.runtimeError(`I tried to lookup ${t}(${r}) but used too few dimensions.`),i}modifyStringSlice(t,r,e,i){return t=t||"",this.checkString(t),this.checkString(r),i||(i=e),e=this.ROUND(e),i=this.ROUND(i),e<1&&this.dialectError("accept a string slice index less than 1"),ir.length)&&this.runtimeError(`I needed a number between 1 and ${r.length}, but I got ${t}.`),t<1||t>r.length?0:t}onGotoLabel(t,...r){t=this.checkOnGoto(t,r),t&&this.gotoLabel(r[t-1])}onGosubLabel(t,...r){t=this.checkOnGoto(t,r),t&&this.gosubLabel(r[t-1])}nextDatum(){return this.dataptr>=this.datums.length&&this.runtimeError("I tried to READ, but ran out of data."),this.datums[this.dataptr++].value}do__PRINT(t){var r="";for(var e of t.args){var i=this.expr2js(e),n=i.name;r+=`this.printExpr(this.checkValue(${i}, ${JSON.stringify(n)}));`}return r}preInput(){this.running=!1,this.curpc--}postInput(t){t&&this.curpc++,this.running=!0,this.resume()}do__INPUT(t){var r=t.prompt!=null?this.expr2js(t.prompt):'""',e=t.elapsed!=null?this.assign2js(t.elapsed):"let ___",i="";return t.args.forEach((n,s)=>{var a=this.assign2js(n);i+=` var value = this.convert(${JSON.stringify(n.name)}, response.vals[${s}]); @@ -34,4 +34,4 @@ import{b as v}from"./chunk-3XE5YOCV.js";import{a as d,o as S}from"./chunk-UC5KI5 `),this.tty.addtext("*** END OF PROGRAM ***",1),this.tty.showPrintHead(!1)}loadROM(t,r){var e=this.runtime.exited;this.program=r;var i=this.runtime.load(r);this.tty.uppercaseOnly=!0,d.input=this.program.opts.uppercaseOnly?n=>n.toUpperCase():null,(!this.hotReload||e||!i)&&this.reset()}getROMExtension(){return".json"}reset(){this.tty.clear(),this.runtime.reset(),this.clock=0,this.transcript=[]}pause(){this.timer.stop()}resume(){this.isBlocked()||(this.animcount=0,this.timer.start())}isBlocked(){return this.tty.waitingfor!=null||this.runtime.exited}isRunning(){return this.timer.isRunning()}getDefaultExtension(){return".bas"}getToolForFilename(){return"basic"}getPresets(){return T}getPC(){return this.runtime.curpc}getSP(){return 4096-this.runtime.returnStack.length}isStable(){return!0}getCPUState(){return{PC:this.getPC(),SP:this.getSP()}}saveState(){return{c:this.getCPUState(),rt:this.runtime.saveState()}}loadState(t){this.runtime.loadState(t)}getDebugTree(){return{CurrentLine:this.runtime.getCurrentLabel(),Variables:this.runtime.vars,Arrays:this.runtime.arrays,Functions:this.runtime.defs,ForLoops:this.runtime.forLoops,WhileLoops:this.runtime.whileLoops,ReturnStack:this.runtime.returnStack,NextDatum:this.runtime.datums[this.runtime.dataptr],Clock:this.clock,Options:this.runtime.opts,Internals:this.runtime}}inspect(t){let r=this.runtime.vars[t];if(r!=null)return`${t} = ${r}`}showHelp(){return"https://8bitworkshop.com/docs/platforms/basic/"}getDebugCategories(){return["Variables"]}getDebugInfo(t,r){switch(t){case"Variables":return this.varsToLongString()}}varsToLongString(){var t="",r=Object.keys(this.runtime.vars);r.sort();for(var e of r){var i=this.runtime.vars[e],n=JSON.stringify(i);n.length>24&&(n=`${n.substr(0,24)}...(${n.length})`),t+=p(e,3)+" = "+n+` `}return t}setupDebug(t){this.onBreakpointHit=t}clearDebug(){this.onBreakpointHit=null,this.debugTrap=null}checkDebugTrap(){return this.debugTrap&&this.debugTrap()?(this.pause(),this.break(),!0):!1}break(){this.onBreakpointHit&&this.onBreakpointHit(this.saveState())}step(){var t=this.clock;this.debugTrap=()=>this.clock>t,this.resume()}stepOver(){var t=this.runtime.getStatement();if(t&&(t.command=="GOSUB"||t.command=="ONGOSUB")){var r=this.getPC()+1;this.runEval(()=>this.getPC()==r)}else this.step()}runUntilReturn(){var t=this.getSP();this.runEval(()=>this.getSP()>t)}runEval(t){this.debugTrap=()=>t(this.getCPUState()),this.resume()}restartAtPC(t){return t=Math.round(t),t>=0&&t=this.MAX_CYCLES){console.log("too many cycles @",i(e),"routine",i(n));break}c=!1,this.WRAP_CLOCKS&&s>=this.MAX_CLOCKS?(s=s%this.MAX_CLOCKS,t=t%this.MAX_CLOCKS):(s=Math.min(this.MAX_CLOCKS,s),t=Math.min(this.MAX_CLOCKS,t));var r=this.getClockCountsAtPC(e),l=this.platform.readAddress(e+1),m=this.platform.readAddress(e+2),u=l+(m<<8),f=e;if(s>=this.pc2minclocks[f]||(this.pc2minclocks[f]=s,c=!0),t<=this.pc2maxclocks[f]||(this.pc2maxclocks[f]=t,c=!0),!r.insnlength){console.log("Illegal instruction!",i(e),i(r.opcode),r);break}e+=r.insnlength;var A=o;switch(o=null,r.opcode){case 25:case 29:case 57:case 61:case 89:case 93:case 121:case 125:case 153:case 157:case 169:case 173:case 185:case 189:case 188:case 190:case 217:case 221:case 249:case 253:l==0&&(r.maxCycles-=1);break;case 133:l==2&&(s=t=0,r.minCycles=r.maxCycles=0);break;case 44:l==2&&m==32&&(s=0,t=4,r.minCycles=r.maxCycles=0);break;case 32:s+=r.minCycles,t+=r.maxCycles,this.traceInstructions(u,s,t,u,o);var a=this.jsrresult[u];a?(s=a.minclocks,t=a.maxclocks):(console.log("No JSR result!",i(e),i(u)),s=t);break;case 76:e=u;break;case 64:x=!0;break;case 96:if(n){var a=this.jsrresult[n];a?a={minclocks:Math.min(s,a.minclocks),maxclocks:Math.max(t,a.maxclocks)}:a={minclocks:s,maxclocks:t},this.jsrresult[n]=a,console.log("RTS",i(e),i(n),this.jsrresult[n])}return;case 16:case 48:case 80:case 112:case 144:case 176:case 208:case 240:var O=e+_(l),y=e>>8!=O>>8;y||r.maxCycles--;var h=p[Math.floor((r.opcode-16)/32)],b=d(A,h[0]),K=d(A,h[1]);this.traceInstructions(O,s+r.maxCycles,t+r.maxCycles,n,h[0]),K===!1&&(console.log("branch always taken",i(e),A,h[1]),x=!0),o=h[1],r.maxCycles=r.minCycles;break;case 108:console.log("Instruction not supported!",i(e),i(r.opcode),r);return}s+=r.minCycles,t+=r.maxCycles}}showLoopTimingForPC(e){this.pc2minclocks={},this.pc2maxclocks={},this.jsrresult={},this.traceInstructions(e|this.platform.getOriginPC(),this.START_CLOCKS,this.MAX_CLOCKS,0,{})}},M=class extends S{constructor(e){super(e);this.MAX_CLOCKS=this.START_CLOCKS=76*4,this.WRAP_CLOCKS=!1}},v=class extends S{constructor(e){super(e);this.MAX_CLOCKS=114,this.START_CLOCKS=0,this.WRAP_CLOCKS=!0}};export{M as a,v as b}; -//# sourceMappingURL=chunk-VFRMSBSH.js.map +import{c as _,g as i}from"./chunk-YL2YTMD7.js";var p=[[{N:0},{N:1}],[{N:1},{N:0}],[{V:0},{V:1}],[{V:1},{V:0}],[{C:0},{C:1}],[{C:1},{C:0}],[{Z:0},{Z:1}],[{Z:1},{Z:0}]];function d(C,e){if(C==null||e==null)return null;for(var s in C)if(e[s]!=="undefined")return C[s]==e[s];for(var s in e)if(C[s]!=="undefined")return C[s]==e[s];return null}var S=class{constructor(e){this.pc2minclocks={};this.pc2maxclocks={};this.jsrresult={};this.MAX_CYCLES=2e3;this.platform=e}getClockCountsAtPC(e){var s=this.platform.readAddress(e),t=this.platform.getOpcodeMetadata(s,e);return t}traceInstructions(e,s,t,n,o){this.WRAP_CLOCKS&&(this.pc2minclocks[e]!==void 0&&(s=Math.min(s,this.pc2minclocks[e])),this.pc2maxclocks[e]!==void 0&&(t=Math.max(t,this.pc2maxclocks[e]))),o||(o={});for(var c=!0,x=!1,L=0;c&&!x;L++){if(L>=this.MAX_CYCLES){console.log("too many cycles @",i(e),"routine",i(n));break}c=!1,this.WRAP_CLOCKS&&s>=this.MAX_CLOCKS?(s=s%this.MAX_CLOCKS,t=t%this.MAX_CLOCKS):(s=Math.min(this.MAX_CLOCKS,s),t=Math.min(this.MAX_CLOCKS,t));var r=this.getClockCountsAtPC(e),l=this.platform.readAddress(e+1),m=this.platform.readAddress(e+2),u=l+(m<<8),f=e;if(s>=this.pc2minclocks[f]||(this.pc2minclocks[f]=s,c=!0),t<=this.pc2maxclocks[f]||(this.pc2maxclocks[f]=t,c=!0),!r.insnlength){console.log("Illegal instruction!",i(e),i(r.opcode),r);break}e+=r.insnlength;var A=o;switch(o=null,r.opcode){case 25:case 29:case 57:case 61:case 89:case 93:case 121:case 125:case 153:case 157:case 169:case 173:case 185:case 189:case 188:case 190:case 217:case 221:case 249:case 253:l==0&&(r.maxCycles-=1);break;case 133:l==2&&(s=t=0,r.minCycles=r.maxCycles=0);break;case 44:l==2&&m==32&&(s=0,t=4,r.minCycles=r.maxCycles=0);break;case 32:s+=r.minCycles,t+=r.maxCycles,this.traceInstructions(u,s,t,u,o);var a=this.jsrresult[u];a?(s=a.minclocks,t=a.maxclocks):(console.log("No JSR result!",i(e),i(u)),s=t);break;case 76:e=u;break;case 64:x=!0;break;case 96:if(n){var a=this.jsrresult[n];a?a={minclocks:Math.min(s,a.minclocks),maxclocks:Math.max(t,a.maxclocks)}:a={minclocks:s,maxclocks:t},this.jsrresult[n]=a,console.log("RTS",i(e),i(n),this.jsrresult[n])}return;case 16:case 48:case 80:case 112:case 144:case 176:case 208:case 240:var O=e+_(l),y=e>>8!=O>>8;y||r.maxCycles--;var h=p[Math.floor((r.opcode-16)/32)],b=d(A,h[0]),K=d(A,h[1]);this.traceInstructions(O,s+r.maxCycles,t+r.maxCycles,n,h[0]),K===!1&&(console.log("branch always taken",i(e),A,h[1]),x=!0),o=h[1],r.maxCycles=r.minCycles;break;case 108:console.log("Instruction not supported!",i(e),i(r.opcode),r);return}s+=r.minCycles,t+=r.maxCycles}}showLoopTimingForPC(e){this.pc2minclocks={},this.pc2maxclocks={},this.jsrresult={},this.traceInstructions(e|this.platform.getOriginPC(),this.START_CLOCKS,this.MAX_CLOCKS,0,{})}},M=class extends S{constructor(e){super(e);this.MAX_CLOCKS=this.START_CLOCKS=76*4,this.WRAP_CLOCKS=!1}},v=class extends S{constructor(e){super(e);this.MAX_CLOCKS=114,this.START_CLOCKS=0,this.WRAP_CLOCKS=!0}};export{M as a,v as b}; +//# sourceMappingURL=chunk-36G23HSA.js.map diff --git a/gen/chunk-VFRMSBSH.js.map b/gen/chunk-36G23HSA.js.map similarity index 100% rename from gen/chunk-VFRMSBSH.js.map rename to gen/chunk-36G23HSA.js.map diff --git a/gen/chunk-47V4PEOO.js b/gen/chunk-47V4PEOO.js deleted file mode 100644 index 440fcb43..00000000 --- a/gen/chunk-47V4PEOO.js +++ /dev/null @@ -1,6 +0,0 @@ -function ne(e,t){for(e+="";e.length0?e.substr(0,t):e}function V(e,t){return t||(t=2),t==8?V(e>>16&65535,4)+V(e&65535,4):D(e,t,16)}function le(e,t){return t||(t=8),D(e,t,2)}function D(e,t,r){try{for(var i=e.toString(r).toUpperCase();i.length=0)for(;n'+c+""),a+=c,n++,s++}for(;s>6)+3,E=(v&63)+8):(K=i[v&31],E=(v>>5)+1),_=0;_=192&&n<224)n=(n&31)<<6|e[i++]&63;else if(n=(n&15)<<12|(e[i]&63)<<6|e[i+1]&63,i+=2,n==65279)continue;t+=String.fromCharCode(n)}return t}function pe(e,t){var r=0;if(e){e=e.toUpperCase();let a=[".CHR",".BIN",".DAT",".PAL",".NAM",".RLE",".LZ4",".NSF"];for(var i of a)e.endsWith(i)&&r++}for(var n=0;n<(t?t.length:0);){let a=t[n++];if((a&128)==0){if(a<9||a>=14&&a<26||a==127){r++;break}}else{var s=0;for((a&224)==192?s=1:(a&240)==224?s=2:(a&248)==240?s=3:(a<160||a==255)&&r++;s--;)if(n>=t.length||(t[n++]&192)!=128){r++;break}}}return r>0}function me(e,t,r){for(var i=r||9,n=t.length,s=e._malloc(n+1),a=0;a0&&(i+=" "),i+=e&s?t[n]:"-"}return i}function xe(e){return(e&255)<<16|e>>16&255|e&65280}function P(e,t,r){return e&255|(t&255)<<8|(r&255)<<16|4278190080}function A(e,t,r){return rt?t:r}function de(e){return e.length==0?"":(e.match(/^[a-zA-Z_]/)||(e="_"+e),e.replace(/\W+/g,"_"))}function ye(e){for(var t=0,r=e[t++],i=[],n=r;t{var i=document.createElement("script");i.onload=t,i.onerror=r,i.src=e,document.getElementsByTagName("head")[0].appendChild(i)})}function Le(e){e.startsWith("?")&&(e=e.substr(1));var t=e.split("&");if(!t||t.length==0)return{};for(var r={},i=0;i1&&rs;){let a=n,o=s;if((n&1)==0&&(o=s*2,a=n/2),n%3==0&&(o=s*3,a=n/3),n%5==0&&(o=s*5,a=n/5),athis.maxSize&&(console.log("cache reset",this),this.reset())}reset(){this.cache=new Map,this.size=0}};function d(e){var t=e&&e.w+"px"||"100%",r=e&&e.h+"px"||"100%",i=this.itemHeight=e.itemHeight;this.items=e.items,this.generatorFn=e.generatorFn,this.totalRows=e.totalRows||e.items&&e.items.length;var n=d.createScroller(i*this.totalRows);this.container=d.createContainer(t,r),this.container.appendChild(n);var s=Math.ceil(e.h/i);this.cachedItemsLen=s*3,this._renderChunk(this.container,0);var a=this,o,c=s*i,l=0;this.rmNodeInterval=setInterval(function(){if(Date.now()-l>100)for(var m=document.querySelectorAll('[data-rm="1"]'),p=0,x=m.length;pc){var x=Math.floor(p/i)-s;a._renderChunk(a.container,x<0?0:x),o=p}l=Date.now(),m.preventDefault&&m.preventDefault()}this.container.addEventListener("scroll",h)}d.prototype.createRow=function(e){var t;if(this.generatorFn)t=this.generatorFn(e);else if(this.items)if(typeof this.items[e]=="string"){var r=document.createTextNode(this.items[e]);t=document.createElement("div"),t.style.height=this.itemHeight+"px",t.appendChild(r)}else t=this.items[e];return t.classList.add("vrow"),t.setAttribute("data-index",""+e),t.style.position="absolute",t.style.top=e*this.itemHeight+"px",t};d.prototype._renderChunk=function(e,t){var r=t+this.cachedItemsLen;r>this.totalRows&&(r=this.totalRows);for(var i=document.createDocumentFragment(),n=t;n>17,e^=e<<5,(w=e)&255}function Re(){return w}function Fe(e){w=e}function W(e,t,r,i){var n=e.createElement("canvas");return n.width=r,n.height=i,n.classList.add("emuvideo"),n.tabIndex=-1,t.appendChild(n),n}var u;(function(o){o[o.KeyDown=1]="KeyDown",o[o.Shift=2]="Shift",o[o.Ctrl=4]="Ctrl",o[o.Alt=8]="Alt",o[o.Meta=16]="Meta",o[o.KeyUp=64]="KeyUp",o[o.KeyPress=128]="KeyPress"})(u||(u={}));function Y(e,t){e.onkeydown=r=>{let i=R(r);t(r.which,r.keyCode,1|i),i||r.preventDefault()},e.onkeyup=r=>{t(r.which,r.keyCode,64|R(r))}}var U=class{constructor(t,r,i,n){this.paddle_x=255;this.paddle_y=255;this.mainElement=t,this.width=r,this.height=i,this.options=n}setRotate(t){var r=this.canvas;t?(r.style.transform="rotate("+t+"deg)",r.width{var i=ee(t,r),n=Math.floor(i.x*255/this.canvas.width),s=Math.floor(i.y*255/this.canvas.height);this.paddle_x=A(0,255,n),this.paddle_y=A(0,255,s)})}},Z=class extends U{constructor(){super(...arguments);this.persistenceAlpha=.5;this.jitter=1;this.gamma=.8;this.COLORS=["#111111","#1111ff","#11ff11","#11ffff","#ff1111","#ff11ff","#ffff11","#ffffff"]}create(){super.create(),this.sx=this.width/1024,this.sy=this.height/1024}clear(){var t=this.ctx;t.globalCompositeOperation="source-over",t.globalAlpha=this.persistenceAlpha,t.fillStyle="#000000",t.fillRect(0,0,this.width,this.height),t.globalAlpha=1,t.globalCompositeOperation="lighter"}drawLine(t,r,i,n,s,a){var o=this.ctx,c=this.sx,l=this.sy;if(s>0){var h=Math.pow(s/255,this.gamma);o.globalAlpha=h,o.lineWidth=3,o.beginPath();var m=this.jitter*(Math.random()-.5),p=this.jitter*(Math.random()-.5);t+=m,i+=m,r+=p,n+=p,o.moveTo(t*c,this.height-r*l),t==i&&r==n?o.lineTo(i*c+1,this.height-n*l):o.lineTo(i*c,this.height-n*l),o.strokeStyle=this.COLORS[a&7],o.stroke()}}},N=class{constructor(t){this.mem=new Uint8Array(new ArrayBuffer(t))}},C=class extends Error{constructor(t,r){super(t);this.$loc=r,Object.setPrototypeOf(this,C.prototype)}},z=!1,q=class{constructor(t,r){this.running=!1;this.pulsing=!1;this.nextts=0;this.useReqAnimFrame=z&&typeof window.requestAnimationFrame=="function";this.frameRate=t,this.intervalMsec=1e3/t,this.callback=r}scheduleFrame(t){var r=i=>{try{this.nextFrame(this.useReqAnimFrame?i:Date.now())}catch(n){throw this.running=!1,this.pulsing=!1,n}};this.useReqAnimFrame?window.requestAnimationFrame(r):setTimeout(r,t)}nextFrame(t){t>this.nextts&&(this.running&&this.callback(),this.nframes==0&&(this.startts=t),this.nframes++==300&&console.log("Avg framerate: "+this.nframes*1e3/(t-this.startts)+" fps")),this.nextts+=this.intervalMsec,t-this.nextts>1e3&&(this.nextts=t),this.running?this.scheduleFrame(this.nextts-t):this.pulsing=!1}isRunning(){return this.running}start(){this.running||(this.running=!0,this.nextts=0,this.nframes=0,this.pulsing||(this.scheduleFrame(0),this.pulsing=!0))}stop(){this.running=!1}};function Oe(e,t,r){for(var i="",n=e.BYTES_PER_ELEMENT||1,s=Math.ceil(16/n),a=e instanceof Float32Array||e instanceof Float64Array,o=0;o{if(!t){r(null,n,s,a);return}var o=t[n];if(o||(o=t[0]),r&&(o||i)&&r(o,n,s,a),o){var c=o.mask;c<0&&(c=-c,a&(1|64)&&(a^=1|64)),a&1?e[o.index]|=c:a&64&&(e[o.index]&=~c)}}}function Ie(e,t,r,i,n){var s=Q(t,r,i,n);return e.setKeyboardEvents(s),new F(s)}function He(e){for(var t=new Map,r=0;r{console.log("Gamepad connected:",r),this.reset()}),window.addEventListener("gamepaddisconnected",r=>{console.log("Gamepad disconnected:",r),this.reset()})}reset(){if(this.active=typeof navigator.getGamepads=="function",this.active){let r=navigator.getGamepads().length;this.state=new Array(r),this.lastState=new Array(r);for(var t=0;tt)throw Error("Data too long, "+e.length+" > "+t);var i=new N(t);return r?i.mem.set(e,t-e.length):i.mem.set(e),i.mem}function j(e,t){var r=this;function i(){var n="";t&&t.gmask&&(n+="a&="+t.gmask+";");for(var s=0;s="+o+" && a<="+c+"){",l&&(n+="a&="+l+";"),n+="return this.__fn"+s+`(a,v)&0xff;} -`}return n+="return 0;",new Function("a","v",n)}return i().bind(r)}function Ge(e,t){return new j(e,t)}function ee(e,t){var r=e.getBoundingClientRect(),i=e.width/r.width,n=e.height/r.height;return{x:(t.clientX-r.left)*i,y:(t.clientY-r.top)*n}}function te(){return $("#booksMenuButton").first().height()}var re=class{constructor(t){var r=document.createElement("div");r.setAttribute("class","memdump"),t.appendChild(r),this.maindiv=r}create(t,r,i){this.getLineAt=i,this.memorylist=new d({w:$(t).width(),h:$(t).height(),itemHeight:te(),totalRows:r,generatorFn:n=>{var s=i(n),a=document.createElement("div");return a.appendChild(document.createTextNode(s.text)),s.clas!=null&&(a.className=s.clas),a}}),$(this.maindiv).append(this.memorylist.container)}refresh(){this.memorylist&&$(this.maindiv).find("[data-index]").each((t,r)=>{var i=r,n=parseInt(i.getAttribute("data-index")),s=i.innerText,a=this.getLineAt(n),o=a.text;if(s!=o&&(i.innerText=o,a.clas!=null&&!i.classList.contains(a.clas))){var c=Array.from(i.classList);c.forEach(l=>i.classList.remove(l)),i.classList.add("vrow"),i.classList.add(a.clas)}})}};function ke(e){let t=.9,r=1.1,i=60,n=e>>4&15,s=e&15,a=n?i:0;n&&(s+=1);let o=((n-1)*25-25)*(2*Math.PI/360),c=256*r*Math.pow(s/16,t),l=a*Math.cos(o),h=a*Math.sin(o);var m=c+.956*l+.621*h,p=c-.272*l-.647*h,x=c-1.107*l+1.704*h;return P(A(0,255,m),A(0,255,p),A(0,255,x))}export{ne as a,ie as b,ae as c,se as d,oe as e,ce as f,V as g,le as h,ue as i,fe as j,he as k,O as l,I as m,H as n,pe as o,me as p,ge as q,ve as r,xe as s,P as t,A as u,de as v,ye as w,be as x,B as y,_e as z,Ae as A,Ke as B,Ee as C,Ve as D,Le as E,we as F,Me as G,X as H,d as I,Ue as J,Ne as K,Re as L,Fe as M,W as N,u as O,U as P,Z as Q,N as R,C as S,q as T,Oe as U,f as V,Q as W,Ie as X,He as Y,F as Z,Be as _,Ge as $,ee as aa,te as ba,re as ca,ke as da}; -//# sourceMappingURL=chunk-47V4PEOO.js.map diff --git a/gen/chunk-5XVCUSSZ.js b/gen/chunk-5XVCUSSZ.js deleted file mode 100644 index 4a743747..00000000 --- a/gen/chunk-5XVCUSSZ.js +++ /dev/null @@ -1,2 +0,0 @@ -var j=Object.create;var e=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames,f=Object.getOwnPropertySymbols,m=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;var h=(a,b,c)=>b in a?e(a,b,{enumerable:!0,configurable:!0,writable:!0,value:c}):a[b]=c,p=(a,b)=>{for(var c in b||(b={}))g.call(b,c)&&h(a,c,b[c]);if(f)for(var c of f(b))n.call(b,c)&&h(a,c,b[c]);return a};var i=a=>e(a,"__esModule",{value:!0});var q=(a=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(a,{get:(b,c)=>(typeof require!="undefined"?require:b)[c]}):a)(function(a){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+a+'" is not supported')});var r=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports),s=(a,b)=>{i(a);for(var c in b)e(a,c,{get:b[c],enumerable:!0})},o=(a,b,c)=>{if(b&&typeof b=="object"||typeof b=="function")for(let d of l(b))!g.call(a,d)&&d!=="default"&&e(a,d,{get:()=>b[d],enumerable:!(c=k(b,d))||c.enumerable});return a},t=a=>o(i(e(a!=null?j(m(a)):{},"default",a&&a.__esModule&&"default"in a?{get:()=>a.default,enumerable:!0}:{value:a,enumerable:!0})),a);export{p as a,q as b,r as c,s as d,t as e}; -//# sourceMappingURL=chunk-5XVCUSSZ.js.map diff --git a/gen/chunk-GBZ35D7O.js b/gen/chunk-ASAEALE3.js similarity index 98% rename from gen/chunk-GBZ35D7O.js rename to gen/chunk-ASAEALE3.js index 5792622f..bb567df9 100644 --- a/gen/chunk-GBZ35D7O.js +++ b/gen/chunk-ASAEALE3.js @@ -1,4 +1,4 @@ -import{c as ae,k as he,n as ne,q as le}from"./chunk-4UNLDFGJ.js";import{W as ie,a as I,g as w,t as c}from"./chunk-47V4PEOO.js";var b;(function(a){a[a.GRAPHICS=0]="GRAPHICS",a[a.TEXT=1]="TEXT",a[a.BITMAP=2]="BITMAP",a[a.MULTICOLOR=3]="MULTICOLOR",a[a.MODE4=4]="MODE4",a[a.BITMAP_TEXT=5]="BITMAP_TEXT",a[a.BITMAP_MULTICOLOR=6]="BITMAP_MULTICOLOR",a[a.ILLEGAL=7]="ILLEGAL"})(b||(b={}));var O=class{constructor(e,t,r){this.probe=new ne;this.ram=new Uint8Array(16384);this.registers=new Uint8Array(8);this.spriteBuffer=new Uint8Array(256);this.displayOn=!1;this.interruptsOn=!1;this.fb32=e,this.cru=t,this.enableFlicker=r,this.palette=[c(0,0,0),c(0,0,0),c(33,200,66),c(94,220,120),c(84,85,237),c(125,118,252),c(212,82,77),c(66,235,245),c(252,85,84),c(255,121,120),c(212,193,84),c(230,206,128),c(33,176,59),c(201,91,186),c(204,204,204),c(255,255,255)]}reset(){var e;this.ram.fill(0),this.registers.fill(0),this.addressRegister=0,this.statusRegister=0,this.prefetchByte=0,this.latch=!1,this.displayOn=!1,this.interruptsOn=!1,this.screenMode=0,this.bitmapMode=!1,this.textMode=!1,this.colorTable=0,this.nameTable=0,this.charPatternTable=0,this.spriteAttributeTable=0,this.spritePatternTable=0,this.colorTableMask=16383,this.patternTableMask=16383,this.ramMask=16383,this.fgColor=0,this.bgColor=0,this.flicker=this.enableFlicker,this.redrawRequired=!0,this.width=304,this.height=240}drawScanline(e){var t=this.fb32,r=this.width,i=e*r,h=this.screenMode,s=this.textMode,l=this.bitmapMode,a=s?240:256,n=192,d=r-a>>1,m=this.height-n>>1,M=this.fgColor,g=this.bgColor,o=this.ram,P=this.nameTable,V=this.colorTable,C=this.charPatternTable,D=this.colorTableMask,H=this.patternTableMask,ce=this.spriteAttributeTable,ue=this.spritePatternTable,Z=(this.registers[1]&2)!=0,y=this.registers[1]&1,$=(Z?16:8)<<(y?1:0),j=this.flicker?4:32,J=this.palette,N=!1,Q=!1,Y=31,R,v,_,f,F,B,p;if(e>=m&&e208&&(k-=256),k++;var X=k+$,L=-1;if(U<8||!l)u>=k&&u=k&&K=64&&u<128&&u>=k&&u>y,pe=ue+(de<<3)+ge,E=0;E<$;E++){var G=te+E;if(G>=0&&G>y,Te=o[pe+(re>=8?16:0)];(Te&128>>(re&7))!=0&&(W[G]===0?W[G]=me+1:N=!0)}}}z++}A+=4}else ee=!0}z>4&&(Q=!0,Y=U)}var S=s?(u>>3)*40:u>>3<<5,x=u&7;for(R=0;R=d&&R>3)],B=o[V+(f>>3)],p=o[C+(f<<3)+x],v=(p&128>>(T&7))!=0?(B&240)>>4:B&15;break;case 2:f=o[P+S+(T>>3)],F=((u&192)<<5)+(f<<3),B=o[V+(F&D)+x],p=o[C+(F&H)+x],v=(p&128>>(T&7))!=0?(B&240)>>4:B&15;break;case 3:f=o[P+S+(T>>3)],x=(u&28)>>2,p=o[C+(f<<3)+x],v=(T&4)==0?(p&240)>>4:p&15;break;case 1:f=o[P+S+Math.floor(T/6)],p=o[C+(f<<3)+x],v=(p&128>>T%6)!=0?M:g;break;case 5:f=o[P+S+Math.floor(T/6)],F=((u&192)<<5)+(f<<3),p=o[C+(F&H)+x],v=(p&128>>T%6)!=0?M:g;break;case 6:f=o[P+S+(T>>3)],x=(u&28)>>2,F=((u&192)<<5)+(f<<3),p=o[C+(F&H)+x],v=(T&4)==0?(p&240)>>4:p&15;break;case 7:v=(T&4)==0?M:g;break}if(v===0&&(v=g),!s){var se=W[T]-1;se>0&&(v=se)}}else v=g;_=J[v],t[i++]=_}}else for(_=J[g],R=0;R>4,this.bgColor=this.registers[7]&15;break}}setVDPWriteCommand3(e){this.setVDPWriteRegister(e)}writeAddress(e){if(!this.latch)this.addressRegister=this.addressRegister&65280|e;else{switch((e&192)>>6){case 0:this.setReadAddress(e);break;case 1:this.setWriteAddress(e);break;case 2:this.setVDPWriteRegister(e);break;case 3:this.setVDPWriteCommand3(e);break}this.redrawRequired=!0}this.latch=!this.latch}updateMode(e,t){if(this.bitmapMode=(e&2)!=0,this.textMode=(t&16)!=0,this.bitmapMode)switch((t&24)>>3){case 0:this.screenMode=2;break;case 1:this.screenMode=6;break;case 2:this.screenMode=5;break;case 3:this.screenMode=7;break}else switch((t&24)>>3){case 0:this.screenMode=0;break;case 1:this.screenMode=3;break;case 2:this.screenMode=1;break;case 3:this.screenMode=7;break}this.bitmapMode?(this.colorTable=(this.registers[3]&128)<<6,this.charPatternTable=(this.registers[4]&4)<<11,this.updateTableMasks()):(this.colorTable=this.registers[3]<<6,this.charPatternTable=(this.registers[4]&7)<<11),this.nameTable=(this.registers[2]&15)<<10,this.spriteAttributeTable=(this.registers[5]&127)<<7,this.spritePatternTable=(this.registers[6]&7)<<11}updateTableMasks(){this.screenMode===2?(this.colorTableMask=(this.registers[3]&127)<<6|63,this.patternTableMask=(this.registers[4]&3)<<11|this.colorTableMask&2047):this.screenMode===5||this.screenMode===6?(this.colorTableMask=this.ramMask,this.patternTableMask=(this.registers[4]&3)<<11|2047):(this.colorTableMask=this.ramMask,this.patternTableMask=this.ramMask)}writeData(e){this.probe.logVRAMWrite(this.addressRegister,e),this.ram[this.addressRegister++]=e,this.prefetchByte=e,this.addressRegister&=this.ramMask,this.latch=!1,this.redrawRequired=!0}readStatus(){var e=this.statusRegister;return this.statusRegister=31,this.interruptsOn&&this.cru.setVDPInterrupt(!1),this.latch=!1,e}readData(){var e=this.prefetchByte;return this.prefetchByte=this.ram[this.addressRegister++],this.probe.logVRAMRead(this.addressRegister-1,this.prefetchByte),this.addressRegister&=this.ramMask,this.latch=!1,e}getRAM(){return this.ram}colorTableSize(){return this.screenMode===0?32:this.screenMode===2?Math.min(this.colorTableMask+1,6144):0}patternTableSize(){return this.bitmapMode?Math.min(this.patternTableMask+1,6144):2048}getDebugTables(){var e=[["Pattern Table",this.charPatternTable,this.patternTableSize()],["Name Table",this.nameTable,768],["Color Table",this.colorTable,this.colorTableSize()],["Sprite Patterns",this.spritePatternTable,64*32],["Sprite Attributes",this.spriteAttributeTable,4*32]];return e}getRegsString(){let e=20;for(var t="Registers:",r=0;r>1,m=this.height-n>>1,M=this.fgColor,g=this.bgColor,o=this.ram,P=this.nameTable,V=this.colorTable,C=this.charPatternTable,D=this.colorTableMask,H=this.patternTableMask,ce=this.spriteAttributeTable,ue=this.spritePatternTable,Z=(this.registers[1]&2)!=0,y=this.registers[1]&1,$=(Z?16:8)<<(y?1:0),j=this.flicker?4:32,J=this.palette,N=!1,Q=!1,Y=31,R,v,_,f,F,B,p;if(e>=m&&e208&&(k-=256),k++;var X=k+$,L=-1;if(U<8||!l)u>=k&&u=k&&K=64&&u<128&&u>=k&&u>y,pe=ue+(de<<3)+ge,E=0;E<$;E++){var G=te+E;if(G>=0&&G>y,Te=o[pe+(re>=8?16:0)];(Te&128>>(re&7))!=0&&(W[G]===0?W[G]=me+1:N=!0)}}}z++}A+=4}else ee=!0}z>4&&(Q=!0,Y=U)}var S=s?(u>>3)*40:u>>3<<5,x=u&7;for(R=0;R=d&&R>3)],B=o[V+(f>>3)],p=o[C+(f<<3)+x],v=(p&128>>(T&7))!=0?(B&240)>>4:B&15;break;case 2:f=o[P+S+(T>>3)],F=((u&192)<<5)+(f<<3),B=o[V+(F&D)+x],p=o[C+(F&H)+x],v=(p&128>>(T&7))!=0?(B&240)>>4:B&15;break;case 3:f=o[P+S+(T>>3)],x=(u&28)>>2,p=o[C+(f<<3)+x],v=(T&4)==0?(p&240)>>4:p&15;break;case 1:f=o[P+S+Math.floor(T/6)],p=o[C+(f<<3)+x],v=(p&128>>T%6)!=0?M:g;break;case 5:f=o[P+S+Math.floor(T/6)],F=((u&192)<<5)+(f<<3),p=o[C+(F&H)+x],v=(p&128>>T%6)!=0?M:g;break;case 6:f=o[P+S+(T>>3)],x=(u&28)>>2,F=((u&192)<<5)+(f<<3),p=o[C+(F&H)+x],v=(T&4)==0?(p&240)>>4:p&15;break;case 7:v=(T&4)==0?M:g;break}if(v===0&&(v=g),!s){var se=W[T]-1;se>0&&(v=se)}}else v=g;_=J[v],t[i++]=_}}else for(_=J[g],R=0;R>4,this.bgColor=this.registers[7]&15;break}}setVDPWriteCommand3(e){this.setVDPWriteRegister(e)}writeAddress(e){if(!this.latch)this.addressRegister=this.addressRegister&65280|e;else{switch((e&192)>>6){case 0:this.setReadAddress(e);break;case 1:this.setWriteAddress(e);break;case 2:this.setVDPWriteRegister(e);break;case 3:this.setVDPWriteCommand3(e);break}this.redrawRequired=!0}this.latch=!this.latch}updateMode(e,t){if(this.bitmapMode=(e&2)!=0,this.textMode=(t&16)!=0,this.bitmapMode)switch((t&24)>>3){case 0:this.screenMode=2;break;case 1:this.screenMode=6;break;case 2:this.screenMode=5;break;case 3:this.screenMode=7;break}else switch((t&24)>>3){case 0:this.screenMode=0;break;case 1:this.screenMode=3;break;case 2:this.screenMode=1;break;case 3:this.screenMode=7;break}this.bitmapMode?(this.colorTable=(this.registers[3]&128)<<6,this.charPatternTable=(this.registers[4]&4)<<11,this.updateTableMasks()):(this.colorTable=this.registers[3]<<6,this.charPatternTable=(this.registers[4]&7)<<11),this.nameTable=(this.registers[2]&15)<<10,this.spriteAttributeTable=(this.registers[5]&127)<<7,this.spritePatternTable=(this.registers[6]&7)<<11}updateTableMasks(){this.screenMode===2?(this.colorTableMask=(this.registers[3]&127)<<6|63,this.patternTableMask=(this.registers[4]&3)<<11|this.colorTableMask&2047):this.screenMode===5||this.screenMode===6?(this.colorTableMask=this.ramMask,this.patternTableMask=(this.registers[4]&3)<<11|2047):(this.colorTableMask=this.ramMask,this.patternTableMask=this.ramMask)}writeData(e){this.probe.logVRAMWrite(this.addressRegister,e),this.ram[this.addressRegister++]=e,this.prefetchByte=e,this.addressRegister&=this.ramMask,this.latch=!1,this.redrawRequired=!0}readStatus(){var e=this.statusRegister;return this.statusRegister=31,this.interruptsOn&&this.cru.setVDPInterrupt(!1),this.latch=!1,e}readData(){var e=this.prefetchByte;return this.prefetchByte=this.ram[this.addressRegister++],this.probe.logVRAMRead(this.addressRegister-1,this.prefetchByte),this.addressRegister&=this.ramMask,this.latch=!1,e}getRAM(){return this.ram}colorTableSize(){return this.screenMode===0?32:this.screenMode===2?Math.min(this.colorTableMask+1,6144):0}patternTableSize(){return this.bitmapMode?Math.min(this.patternTableMask+1,6144):2048}getDebugTables(){var e=[["Pattern Table",this.charPatternTable,this.patternTableSize()],["Name Table",this.nameTable,768],["Color Table",this.colorTable,this.colorTableSize()],["Sprite Patterns",this.spritePatternTable,64*32],["Sprite Attributes",this.spriteAttributeTable,4*32]];return e}getRegsString(){let e=20;for(var t="Registers:",r=0;r0&&(t+=I(h[0],e)+": $"+w(h[1],4)+" - $"+w(h[1]+h[2]-1,4)+` `);return t+=I("Address Register",e)+": $"+w(this.addressRegister,4)+` @@ -8,4 +8,4 @@ import{c as ae,k as he,n as ne,q as le}from"./chunk-4UNLDFGJ.js";import{W as ie, `,this.ramMask!=16383&&(t+=I("RAM Mask",e)+": $"+w(this.ramMask)+` `),t}hexView(e,t,r){for(var i="",h=null,s=e,l=0,a=0;a>2&3)*85,(e>>4&3)*85),this.prefetchByte=e,this.addressRegister&=this.ramMask,this.redrawRequired=!0}else{var r=this.addressRegister;super.writeData(e),this.writeTwiddled(r,e)}this.latch=!1}writeTwiddled(e,t){for(var r=e&16380,i=r*2,h=this.ram[r],s=this.ram[r+1],l=this.ram[r+2],a=this.ram[r+3],n=0;n<8;++n){var d=7-n,m=h>>>d&1|(s>>>d&1)<<1|(l>>>d&1)<<2|(a>>>d&1)<<3;this.vramUntwiddled[i+n]=m}}getState(){var e=super.getState();return e.cram=this.cram.slice(0),e}restoreState(e){super.restoreState(e),this.cram.set(e.cram)}drawScanline(e){this.screenMode==4?this.rasterize_line(e):super.drawScanline(e)}findSprites(e){var t=this.spriteAttributeTable,r=[],i=8,h;for(this.registers[1]&2&&(i=16),h=0;h<64;h++){var s=this.ram[t+h];if(s===208)break;if(s>=240&&(s-=256),e>=s&&e=8)){a=!0;var P=e-M[2],V=h+M[1]*32+P*4,C=V*2+g,D=this.vramUntwiddled[C];if(D!==0){if(n){this.statusRegister|=32;break}this.fb32[t+(r+s-this.registers[8]&255)]=this.cpalette[16+D],n=!0}}}!a&&d>1&&(s+=d-1)}}border_clear(e,t){e=e|0,t=t|0;let r=16+(this.registers[7]&15),i=this.cpalette[r];this.fb32.fill(i,e,e+t)}rasterize_line(e){e|=0;var t=this.registers,r=256,i=this.numVisibleLines,h=this.width-r>>1,s=this.height-i>>1;let l=(e+s)*this.width|0,a=l+h|0;if(!this.displayOn||e<0||e>=i)e=262-s&&this.border_clear((e-262+s)*this.width,this.width);else{var n=e+t[9];n>=224&&(n-=224);let d=this.findSprites(e),m=t[0]&64&&e<16?0:t[8],M=this.nameTable+(n>>>3)*64,g=n&7;this.rasterize_background_line(a,m,M,g),this.rasterize_sprites(e,a,m,d),this.rasterize_foreground_line(a,m,M,g),this.border_clear(l,h),this.border_clear(a+256,h),t[0]&1<<5&&this.border_clear(a,8)}e==i&&(this.statusRegister|=128,this.interruptsOn&&this.cru.setVDPInterrupt(!0)),e<=i?this.lineCounter>0?this.lineCounter--:(this.lineCounter=this.registers[10],this.lineInterruptPending=!0):this.lineCounter=this.registers[10],this.lineInterruptPending&&this.registers[0]&16}getDebugTables(){if(this.screenMode==4){var e=[["Pattern Table",0,512*32],["Name Table",this.nameTable,32*32*2],["Sprite Attributes",this.spriteAttributeTable,256]];return e}else return super.getDebugTables()}},fe=class extends be{constructor(){super(...arguments);this.cram=new Uint8Array(64);this.cram_latch=0}writeData(e){if(this.writeToCRAM){if(this.addressRegister&1){let t=this.cram_latch+(e<<8),r=c((t&15)*17,(t>>4&15)*17,(t>>8&15)*17),i=this.addressRegister&this.cram.length-1;this.cram[i-1]=this.cram_latch,this.cram[i]=e,this.cpalette[i>>1]=r,this.prefetchByte=e,this.addressRegister&=this.ramMask,this.redrawRequired=!0}else this.cram_latch=e;this.addressRegister++}else super.writeData(e);this.latch=!1}};var oe=2,ve=class extends le{constructor(){super(...arguments);this.cpuFrequency=3579545;this.canvasWidth=304;this.numTotalScanlines=262;this.numVisibleScanlines=240;this.cpuCyclesPerLine=this.cpuFrequency/(262*60);this.sampleRate=262*60*oe;this.overscan=!0;this.cpu=new ae}getKeyboardFunction(){return null}init(e,t,r){this.connectCPUMemoryBus(e),this.connectCPUIOBus(t),this.handler=ie(this.inputs,this.getKeyboardMap(),this.getKeyboardFunction()),this.psg=r,this.audioadapter=r&&new he(r.psg,oe,this.sampleRate)}connectVideo(e){super.connectVideo(e);var t={setVDPInterrupt:r=>{r&&this.vdpInterrupt()}};this.vdp=this.newVDP(this.pixels,t,!0)}connectProbe(e){super.connectProbe(e),this.vdp.probe=e||this.nullProbe}newVDP(e,t,r){return new O(e,t,r)}startScanline(){this.audio&&this.audioadapter&&this.audioadapter.generate(this.audio)}drawScanline(){this.vdp.drawScanline(this.scanline)}loadState(e){super.loadState(e),this.vdp.restoreState(e.vdp)}saveState(){var e=super.saveState();return e.vdp=this.vdp.getState(),e}reset(){super.reset(),this.vdp.reset(),this.psg.reset()}getDebugCategories(){return["CPU","Stack","VDP"]}getDebugInfo(e,t){switch(e){case"VDP":return this.vdpStateToLongString(t.vdp)}}vdpStateToLongString(e){return this.vdp.getRegsString()}readVRAMAddress(e){return this.vdp.ram[e&16383]}};export{be as a,fe as b,ve as c}; -//# sourceMappingURL=chunk-GBZ35D7O.js.map +//# sourceMappingURL=chunk-ASAEALE3.js.map diff --git a/gen/chunk-GBZ35D7O.js.map b/gen/chunk-ASAEALE3.js.map similarity index 100% rename from gen/chunk-GBZ35D7O.js.map rename to gen/chunk-ASAEALE3.js.map diff --git a/gen/chunk-7TOHRG6S.js b/gen/chunk-BMGQJMLR.js similarity index 97% rename from gen/chunk-7TOHRG6S.js rename to gen/chunk-BMGQJMLR.js index 03212bb3..2d16c6ce 100644 --- a/gen/chunk-7TOHRG6S.js +++ b/gen/chunk-BMGQJMLR.js @@ -1,4 +1,4 @@ -import{A as C,C as w,a as p,b as P}from"./chunk-4UNLDFGJ.js";import{P as b,R as v,T as S}from"./chunk-47V4PEOO.js";var m=class{constructor(t){this.loaded=!1;this.preinitted=!1;this.started=!1;this.romtype="cart";this.running=!1;this.initluavars=!1;this.mainElement=t,this.timer=new S(20,this.poll.bind(this))}luacall(t){return this.js_lua_string||(this.js_lua_string=Module.cwrap("_Z13js_lua_stringPKc","string",["string"])),this.js_lua_string(t||"")}_pause(){this.running=!1,this.timer.stop()}pause(){this.loaded&&this.running&&(this.luacall("emu.pause()"),this._pause())}_resume(){this.luacall("emu.unpause()"),this.running=!0,this.timer.start()}resume(){this.loaded&&!this.running&&this._resume()}reset(){this.loaded&&(this.luacall("manager:machine():soft_reset()"),this.running=!0,this.initluavars=!1)}isRunning(){return this.running}bufferConsoleOutput(t){typeof t=="string"&&console.log(t)}startModule(t,e){this.started=!0;var r=this.romfn=this.romfn||e.romfn,a=this.romdata=this.romdata||e.romdata||new v(e.romsize).mem,o=this.romtype=this.romtype||e.romtype,n=this.video=new b(this.mainElement,e.width,e.height);n.create(),$(n.canvas).attr("id","canvas"),console.log("loading",e.jsfile);var u=[e.driver,"-debug","-debugger","none","-verbose","-window","-nokeepaspect","-resolution",n.canvas.width+"x"+n.canvas.height];r&&u.push("-"+o,r),e.extraargs&&(u=u.concat(e.extraargs)),console.log(u),window.JSMESS={},window.Module={arguments:u,screenIsReadOnly:!0,print:this.bufferConsoleOutput,canvas:n.canvas,doNotCaptureKeyboard:!0,keyboardListeningElement:n.canvas,preInit:()=>{console.log("loading FS"),ENV.SDL_EMSCRIPTEN_KEYBOARD_ELEMENT="canvas",e.cfgfile&&(FS.mkdir("/cfg"),FS.writeFile("/cfg/"+e.cfgfile,e.cfgdata,{encoding:"utf8"})),e.biosfile&&(FS.mkdir("/roms"),FS.mkdir("/roms/"+e.driver),FS.writeFile("/roms/"+e.biosfile,e.biosdata,{encoding:"binary"})),FS.mkdir("/emulator"),r&&FS.writeFile(r,a,{encoding:"binary"}),e.preInit&&e.preInit(self),this.preinitted=!0},preRun:[()=>{$(n.canvas).click(i=>{n.canvas.focus()}),this.loaded=!0,console.log("about to run...")}]};var d,c,g=$.Deferred(),f=$.Deferred();if(e.cfgfile&&(d=$.get("mame/cfg/"+e.cfgfile,i=>{e.cfgdata=i,console.log("loaded "+e.cfgfile)},"text")),e.biosfile){var s=new XMLHttpRequest;s.open("GET","mame/roms/"+e.biosfile,!0),s.responseType="arraybuffer",s.onload=i=>{e.biosdata=new Uint8Array(s.response),console.log("loaded "+e.biosfile),g.resolve()},s.ontimeout=function(i){throw Error("Timeout loading "+e.biosfile)},s.send()}else g.resolve();c=$.get("mame/debugger.lua",i=>{this.luadebugscript=i,console.log("loaded debugger.lua")},"text");{var l=new XMLHttpRequest;l.open("GET","mame/"+e.jsfile.replace(".js",".wasm"),!0),l.responseType="arraybuffer",l.onload=i=>{console.log("loaded WASM file"),window.Module.wasmBinary=new Uint8Array(l.response),f.resolve()},l.ontimeout=function(i){throw Error("Timeout loading "+e.jsfile)},l.send()}$.when(c,d,g,f).done(()=>{var i=document.createElement("script");i.src="mame/"+e.jsfile,document.getElementsByTagName("head")[0].appendChild(i),console.log("created script element")}),window.mamelua=i=>(this.initlua(),[i,this.luacall(i)])}loadROMFile(t){this.romdata=t,this.preinitted&&this.romfn&&FS.writeFile(this.romfn,t,{encoding:"binary"})}loadRegion(t,e){if(this.loaded&&e.length>0){for(var r='rgn = manager:machine():memory().regions["'+t+`"] +import{A as C,C as w,a as p,b as P}from"./chunk-GKVIY6GD.js";import{N as b,P as v,R as S}from"./chunk-YL2YTMD7.js";var m=class{constructor(t){this.loaded=!1;this.preinitted=!1;this.started=!1;this.romtype="cart";this.running=!1;this.initluavars=!1;this.mainElement=t,this.timer=new S(20,this.poll.bind(this))}luacall(t){return this.js_lua_string||(this.js_lua_string=Module.cwrap("_Z13js_lua_stringPKc","string",["string"])),this.js_lua_string(t||"")}_pause(){this.running=!1,this.timer.stop()}pause(){this.loaded&&this.running&&(this.luacall("emu.pause()"),this._pause())}_resume(){this.luacall("emu.unpause()"),this.running=!0,this.timer.start()}resume(){this.loaded&&!this.running&&this._resume()}reset(){this.loaded&&(this.luacall("manager:machine():soft_reset()"),this.running=!0,this.initluavars=!1)}isRunning(){return this.running}bufferConsoleOutput(t){typeof t=="string"&&console.log(t)}startModule(t,e){this.started=!0;var r=this.romfn=this.romfn||e.romfn,a=this.romdata=this.romdata||e.romdata||new v(e.romsize).mem,o=this.romtype=this.romtype||e.romtype,n=this.video=new b(this.mainElement,e.width,e.height);n.create(),$(n.canvas).attr("id","canvas"),console.log("loading",e.jsfile);var u=[e.driver,"-debug","-debugger","none","-verbose","-window","-nokeepaspect","-resolution",n.canvas.width+"x"+n.canvas.height];r&&u.push("-"+o,r),e.extraargs&&(u=u.concat(e.extraargs)),console.log(u),window.JSMESS={},window.Module={arguments:u,screenIsReadOnly:!0,print:this.bufferConsoleOutput,canvas:n.canvas,doNotCaptureKeyboard:!0,keyboardListeningElement:n.canvas,preInit:()=>{console.log("loading FS"),ENV.SDL_EMSCRIPTEN_KEYBOARD_ELEMENT="canvas",e.cfgfile&&(FS.mkdir("/cfg"),FS.writeFile("/cfg/"+e.cfgfile,e.cfgdata,{encoding:"utf8"})),e.biosfile&&(FS.mkdir("/roms"),FS.mkdir("/roms/"+e.driver),FS.writeFile("/roms/"+e.biosfile,e.biosdata,{encoding:"binary"})),FS.mkdir("/emulator"),r&&FS.writeFile(r,a,{encoding:"binary"}),e.preInit&&e.preInit(self),this.preinitted=!0},preRun:[()=>{$(n.canvas).click(i=>{n.canvas.focus()}),this.loaded=!0,console.log("about to run...")}]};var d,c,g=$.Deferred(),f=$.Deferred();if(e.cfgfile&&(d=$.get("mame/cfg/"+e.cfgfile,i=>{e.cfgdata=i,console.log("loaded "+e.cfgfile)},"text")),e.biosfile){var s=new XMLHttpRequest;s.open("GET","mame/roms/"+e.biosfile,!0),s.responseType="arraybuffer",s.onload=i=>{e.biosdata=new Uint8Array(s.response),console.log("loaded "+e.biosfile),g.resolve()},s.ontimeout=function(i){throw Error("Timeout loading "+e.biosfile)},s.send()}else g.resolve();c=$.get("mame/debugger.lua",i=>{this.luadebugscript=i,console.log("loaded debugger.lua")},"text");{var l=new XMLHttpRequest;l.open("GET","mame/"+e.jsfile.replace(".js",".wasm"),!0),l.responseType="arraybuffer",l.onload=i=>{console.log("loaded WASM file"),window.Module.wasmBinary=new Uint8Array(l.response),f.resolve()},l.ontimeout=function(i){throw Error("Timeout loading "+e.jsfile)},l.send()}$.when(c,d,g,f).done(()=>{var i=document.createElement("script");i.src="mame/"+e.jsfile,document.getElementsByTagName("head")[0].appendChild(i),console.log("created script element")}),window.mamelua=i=>(this.initlua(),[i,this.luacall(i)])}loadROMFile(t){this.romdata=t,this.preinitted&&this.romfn&&FS.writeFile(this.romfn,t,{encoding:"binary"})}loadRegion(t,e){if(this.loaded&&e.length>0){for(var r='rgn = manager:machine():memory().regions["'+t+`"] `,a=0;a{(function(l){if(typeof Os=="object"&&typeof pa!="undefined")pa.exports=l();else if(typeof define=="function"&&define.amd)define([],l);else{var t;typeof window!="undefined"?t=window:typeof global!="undefined"?t=global:typeof self!="undefined"?t=self:t=this,t.localforage=l()}})(function(){var l,t,r;return function a(u,d,m){function b(W,fe){if(!d[W]){if(!u[W]){var z=typeof li=="function"&&li;if(!fe&&z)return z(W,!0);if(y)return y(W,!0);var H=new Error("Cannot find module '"+W+"'");throw H.code="MODULE_NOT_FOUND",H}var V=d[W]={exports:{}};u[W][0].call(V.exports,function(de){var K=u[W][1][de];return b(K||de)},V,V.exports,a,u,d,m)}return d[W].exports}for(var y=typeof li=="function"&&li,L=0;L=43)}}).catch(function(){return!1})}function _e(p){return typeof Ce=="boolean"?z.resolve(Ce):oe(p).then(function(S){return Ce=S,Ce})}function ze(p){var S=be[p.name],v={};v.promise=new z(function(C,k){v.resolve=C,v.reject=k}),S.deferredOperations.push(v),S.dbReady?S.dbReady=S.dbReady.then(function(){return v.promise}):S.dbReady=v.promise}function Me(p){var S=be[p.name],v=S.deferredOperations.pop();if(v)return v.resolve(),v.promise}function nt(p,S){var v=be[p.name],C=v.deferredOperations.pop();if(C)return C.reject(S),C.promise}function Ke(p,S){return new z(function(v,C){if(be[p.name]=be[p.name]||ar(),p.db)if(S)ze(p),p.db.close();else return v(p.db);var k=[p.name];S&&k.push(p.version);var _=L.open.apply(L,k);S&&(_.onupgradeneeded=function(N){var B=_.result;try{B.createObjectStore(p.storeName),N.oldVersion<=1&&B.createObjectStore(xe)}catch(q){if(q.name==="ConstraintError")console.warn('The database "'+p.name+'" has been upgraded from version '+N.oldVersion+" to version "+N.newVersion+', but the storage "'+p.storeName+'" already exists.');else throw q}}),_.onerror=function(N){N.preventDefault(),C(_.error)},_.onsuccess=function(){var N=_.result;N.onversionchange=function(B){B.target.close()},v(N),Me(p)}})}function bt(p){return Ke(p,!1)}function nr(p){return Ke(p,!0)}function Sr(p,S){if(!p.db)return!0;var v=!p.db.objectStoreNames.contains(p.storeName),C=p.versionp.db.version;if(C&&(p.version!==S&&console.warn('The database "'+p.name+`" can't be downgraded from version `+p.db.version+" to version "+p.version+"."),p.version=p.db.version),k||v){if(v){var _=p.db.version+1;_>p.version&&(p.version=_)}return!0}return!1}function Nr(p){return new z(function(S,v){var C=new FileReader;C.onerror=v,C.onloadend=function(k){var _=btoa(k.target.result||"");S({__local_forage_encoded_blob:!0,data:_,type:p.type})},C.readAsBinaryString(p)})}function Qt(p){var S=ae(atob(p.data));return fe([S],{type:p.type})}function Or(p){return p&&p.__local_forage_encoded_blob}function yt(p){var S=this,v=S._initReady().then(function(){var C=be[S._dbInfo.name];if(C&&C.dbReady)return C.dbReady});return V(v,p,p),v}function Ln(p){ze(p);for(var S=be[p.name],v=S.forages,C=0;C0&&(!p.db||_.name==="InvalidStateError"||_.name==="NotFoundError"))return z.resolve().then(function(){if(!p.db||_.name==="NotFoundError"&&!p.db.objectStoreNames.contains(p.storeName)&&p.version<=p.db.version)return p.db&&(p.version=p.db.version+1),nr(p)}).then(function(){return Ln(p).then(function(){Ze(p,S,v,C-1)})}).catch(v);v(_)}}function ar(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function Di(p){var S=this,v={db:null};if(p)for(var C in p)v[C]=p[C];var k=be[v.name];k||(k=ar(),be[v.name]=k),k.forages.push(S),S._initReady||(S._initReady=S.ready,S.ready=yt);var _=[];function N(){return z.resolve()}for(var B=0;B>4,Y[k++]=(N&15)<<4|B>>2,Y[k++]=(B&3)<<6|q&63;return G}function et(p){var S=new Uint8Array(p),v="",C;for(C=0;C>2],v+=$e[(S[C]&3)<<4|S[C+1]>>4],v+=$e[(S[C+1]&15)<<2|S[C+2]>>6],v+=$e[S[C+2]&63];return S.length%3==2?v=v.substring(0,v.length-1)+"=":S.length%3==1&&(v=v.substring(0,v.length-2)+"=="),v}function tt(p,S){var v="";if(p&&(v=Ur.call(p)),p&&(v==="[object ArrayBuffer]"||p.buffer&&Ur.call(p.buffer)==="[object ArrayBuffer]")){var C,k=Tr;p instanceof ArrayBuffer?(C=p,k+=kr):(C=p.buffer,v==="[object Int8Array]"?k+=wt:v==="[object Uint8Array]"?k+=Lt:v==="[object Uint8ClampedArray]"?k+=Wt:v==="[object Int16Array]"?k+=Fi:v==="[object Uint16Array]"?k+=Wr:v==="[object Int32Array]"?k+=lr:v==="[object Uint32Array]"?k+=Br:v==="[object Float32Array]"?k+=Ri:v==="[object Float64Array]"?k+=Bt:S(new Error("Failed to get type for BinaryArray"))),S(k+et(C))}else if(v==="[object Blob]"){var _=new FileReader;_.onload=function(){var N=Nn+p.type+"~"+et(this.result);S(Tr+$t+N)},_.readAsArrayBuffer(p)}else try{S(JSON.stringify(p))}catch(N){console.error("Couldn't convert value into a JSON string: ",p),S(null,N)}}function Hr(p){if(p.substring(0,Cr)!==Tr)return JSON.parse(p);var S=p.substring(Jt),v=p.substring(Cr,Jt),C;if(v===$t&&Li.test(S)){var k=S.match(Li);C=k[1],S=S.substring(k[0].length)}var _=jr(S);switch(v){case kr:return _;case $t:return fe([_],{type:C});case wt:return new Int8Array(_);case Lt:return new Uint8Array(_);case Wt:return new Uint8ClampedArray(_);case Fi:return new Int16Array(_);case Wr:return new Uint16Array(_);case lr:return new Int32Array(_);case Br:return new Uint32Array(_);case Ri:return new Float32Array(_);case Bt:return new Float64Array(_);default:throw new Error("Unkown type: "+v)}}var zr={serialize:tt,deserialize:Hr,stringToBuffer:jr,bufferToString:et};function Vr(p,S,v,C){p.executeSql("CREATE TABLE IF NOT EXISTS "+S.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],v,C)}function Ii(p){var S=this,v={db:null};if(p)for(var C in p)v[C]=typeof p[C]!="string"?p[C].toString():p[C];var k=new z(function(_,N){try{v.db=openDatabase(v.name,String(v.version),v.description,v.size)}catch(B){return N(B)}v.db.transaction(function(B){Vr(B,v,function(){S._dbInfo=v,_()},function(q,G){N(G)})},N)});return v.serializer=zr,k}function at(p,S,v,C,k,_){p.executeSql(v,C,k,function(N,B){B.code===B.SYNTAX_ERR?N.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[S.storeName],function(q,G){G.rows.length?_(q,B):Vr(q,S,function(){q.executeSql(v,C,k,_)},_)},_):_(N,B)},_)}function Kt(p,S){var v=this;p=de(p);var C=new z(function(k,_){v.ready().then(function(){var N=v._dbInfo;N.db.transaction(function(B){at(B,N,"SELECT * FROM "+N.storeName+" WHERE key = ? LIMIT 1",[p],function(q,G){var Y=G.rows.length?G.rows.item(0).value:null;Y&&(Y=N.serializer.deserialize(Y)),k(Y)},function(q,G){_(G)})})}).catch(_)});return H(C,S),C}function On(p,S){var v=this,C=new z(function(k,_){v.ready().then(function(){var N=v._dbInfo;N.db.transaction(function(B){at(B,N,"SELECT * FROM "+N.storeName,[],function(q,G){for(var Y=G.rows,Z=Y.length,ye=0;ye0){N(Mi.apply(k,[p,q,v,C-1]));return}B(ye)}})})}).catch(B)});return H(_,v),_}function qr(p,S,v){return Mi.apply(this,[p,S,v,1])}function Pr(p,S){var v=this;p=de(p);var C=new z(function(k,_){v.ready().then(function(){var N=v._dbInfo;N.db.transaction(function(B){at(B,N,"DELETE FROM "+N.storeName+" WHERE key = ?",[p],function(){k()},function(q,G){_(G)})})}).catch(_)});return H(C,S),C}function $n(p){var S=this,v=new z(function(C,k){S.ready().then(function(){var _=S._dbInfo;_.db.transaction(function(N){at(N,_,"DELETE FROM "+_.storeName,[],function(){C()},function(B,q){k(q)})})}).catch(k)});return H(v,p),v}function Wn(p){var S=this,v=new z(function(C,k){S.ready().then(function(){var _=S._dbInfo;_.db.transaction(function(N){at(N,_,"SELECT COUNT(key) as c FROM "+_.storeName,[],function(B,q){var G=q.rows.item(0).c;C(G)},function(B,q){k(q)})})}).catch(k)});return H(v,p),v}function Bn(p,S){var v=this,C=new z(function(k,_){v.ready().then(function(){var N=v._dbInfo;N.db.transaction(function(B){at(B,N,"SELECT key FROM "+N.storeName+" WHERE id = ? LIMIT 1",[p+1],function(q,G){var Y=G.rows.length?G.rows.item(0).key:null;k(Y)},function(q,G){_(G)})})}).catch(_)});return H(C,S),C}function Ni(p){var S=this,v=new z(function(C,k){S.ready().then(function(){var _=S._dbInfo;_.db.transaction(function(N){at(N,_,"SELECT key FROM "+_.storeName,[],function(B,q){for(var G=[],Y=0;Y '__WebKitDatabaseInfoTable__'",[],function(k,_){for(var N=[],B=0;B<_.rows.length;B++)N.push(_.rows.item(B).name);S({db:p,storeNames:N})},function(k,_){v(_)})},function(C){v(C)})})}function jn(p,S){S=K.apply(this,arguments);var v=this.config();p=typeof p!="function"&&p||{},p.name||(p.name=p.name||v.name,p.storeName=p.storeName||v.storeName);var C=this,k;return p.name?k=new z(function(_){var N;p.name===v.name?N=C._dbInfo.db:N=openDatabase(p.name,"","",0),p.storeName?_({db:N,storeNames:[p.storeName]}):_(Un(N))}).then(function(_){return new z(function(N,B){_.db.transaction(function(q){function G(ke){return new z(function(Pe,We){q.executeSql("DROP TABLE IF EXISTS "+ke,[],function(){Pe()},function(Fe,st){We(st)})})}for(var Y=[],Z=0,ye=_.storeNames.length;Z0}function Yr(p){var S=this,v={};if(p)for(var C in p)v[C]=p[C];return v.keyPrefix=Ut(p,S._defaultConfig),Gr()?(S._dbInfo=v,v.serializer=zr,z.resolve()):z.reject()}function Ar(p){var S=this,v=S.ready().then(function(){for(var C=S._dbInfo.keyPrefix,k=localStorage.length-1;k>=0;k--){var _=localStorage.key(k);_.indexOf(C)===0&&localStorage.removeItem(_)}});return H(v,p),v}function Wi(p,S){var v=this;p=de(p);var C=v.ready().then(function(){var k=v._dbInfo,_=localStorage.getItem(k.keyPrefix+p);return _&&(_=k.serializer.deserialize(_)),_});return H(C,S),C}function zn(p,S){var v=this,C=v.ready().then(function(){for(var k=v._dbInfo,_=k.keyPrefix,N=_.length,B=localStorage.length,q=1,G=0;G=0;N--){var B=localStorage.key(N);B.indexOf(_)===0&&localStorage.removeItem(B)}}):k=z.reject("Invalid arguments"),H(k,S),k}var zi={_driver:"localStorageWrapper",_initStorage:Yr,_support:Hn(),iterate:zn,getItem:Wi,setItem:ji,removeItem:Ui,clear:Ar,length:ur,key:Bi,keys:Vn,dropInstance:Hi},qn=function(S,v){return S===v||typeof S=="number"&&typeof v=="number"&&isNaN(S)&&isNaN(v)},Xr=function(S,v){for(var C=S.length,k=0;k{(function(l,t){"use strict";typeof cn=="object"&&typeof cn.exports=="object"?cn.exports=l.document?t(l,!0):function(r){if(!r.document)throw new Error("jQuery requires a window with a document");return t(r)}:t(l)})(typeof window!="undefined"?window:Us,function(l,t){"use strict";var r=[],a=Object.getPrototypeOf,u=r.slice,d=r.flat?function(e){return r.flat.call(e)}:function(e){return r.concat.apply([],e)},m=r.push,b=r.indexOf,y={},L=y.toString,W=y.hasOwnProperty,fe=W.toString,z=fe.call(Object),H={},V=function(i){return typeof i=="function"&&typeof i.nodeType!="number"&&typeof i.item!="function"},de=function(i){return i!=null&&i===i.window},K=l.document,xe={type:!0,src:!0,nonce:!0,noModule:!0};function Ce(e,i,n){n=n||K;var s,c,f=n.createElement("script");if(f.text=e,i)for(s in xe)c=i[s]||i.getAttribute&&i.getAttribute(s),c&&f.setAttribute(s,c);n.head.appendChild(f).parentNode.removeChild(f)}function be(e){return e==null?e+"":typeof e=="object"||typeof e=="function"?y[L.call(e)]||"object":typeof e}var Se="3.6.3",o=function(e,i){return new o.fn.init(e,i)};o.fn=o.prototype={jquery:Se,constructor:o,length:0,toArray:function(){return u.call(this)},get:function(e){return e==null?u.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var i=o.merge(this.constructor(),e);return i.prevObject=this,i},each:function(e){return o.each(this,e)},map:function(e){return this.pushStack(o.map(this,function(i,n){return e.call(i,n,i)}))},slice:function(){return this.pushStack(u.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},even:function(){return this.pushStack(o.grep(this,function(e,i){return(i+1)%2}))},odd:function(){return this.pushStack(o.grep(this,function(e,i){return i%2}))},eq:function(e){var i=this.length,n=+e+(e<0?i:0);return this.pushStack(n>=0&&n0&&i-1 in e}var ae=function(e){var i,n,s,c,f,h,E,x,D,R,U,F,I,ie,ve,re,qe,Ve,ht,De="sizzle"+1*new Date,me=e.document,ut=0,Te=0,Be=Ji(),ni=Ji(),Yi=Ji(),pt=Ji(),dr=function(g,w){return g===w&&(U=!0),0},hr={}.hasOwnProperty,ct=[],er=ct.pop,Et=ct.push,tr=ct.push,gs=ct.slice,pr=function(g,w){for(var T=0,M=g.length;T+~]|"+Ae+")"+Ae+"*"),qo=new RegExp(Ae+"|>"),Go=new RegExp(ea),Yo=new RegExp("^"+gr+"$"),Qi={ID:new RegExp("^#("+gr+")"),CLASS:new RegExp("^\\.("+gr+")"),TAG:new RegExp("^("+gr+"|[*])"),ATTR:new RegExp("^"+ms),PSEUDO:new RegExp("^"+ea),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+Ae+"*(even|odd|(([+-]|)(\\d*)n|)"+Ae+"*(?:([+-]|)"+Ae+"*(\\d+)|))"+Ae+"*\\)|)","i"),bool:new RegExp("^(?:"+Zn+")$","i"),needsContext:new RegExp("^"+Ae+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+Ae+"*((?:-\\d)?\\d*)"+Ae+"*\\)|)(?=[^-]|$)","i")},Xo=/HTML$/i,Qo=/^(?:input|select|textarea|button)$/i,Jo=/^h\d$/i,ai=/^[^{]+\{\s*\[native \w/,Ko=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ta=/[+~]/,zt=new RegExp("\\\\[\\da-fA-F]{1,6}"+Ae+"?|\\\\([^\\r\\n\\f])","g"),Vt=function(g,w){var T="0x"+g.slice(1)-65536;return w||(T<0?String.fromCharCode(T+65536):String.fromCharCode(T>>10|55296,T&1023|56320))},bs=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ys=function(g,w){return w?g==="\0"?"\uFFFD":g.slice(0,-1)+"\\"+g.charCodeAt(g.length-1).toString(16)+" ":"\\"+g},xs=function(){F()},Zo=Zi(function(g){return g.disabled===!0&&g.nodeName.toLowerCase()==="fieldset"},{dir:"parentNode",next:"legend"});try{tr.apply(ct=gs.call(me.childNodes),me.childNodes),ct[me.childNodes.length].nodeType}catch(g){tr={apply:ct.length?function(w,T){Et.apply(w,gs.call(T))}:function(w,T){for(var M=w.length,P=0;w[M++]=T[P++];);w.length=M-1}}}function Re(g,w,T,M){var P,O,j,Q,J,ue,se,he=w&&w.ownerDocument,we=w?w.nodeType:9;if(T=T||[],typeof g!="string"||!g||we!==1&&we!==9&&we!==11)return T;if(!M&&(F(w),w=w||I,ve)){if(we!==11&&(J=Ko.exec(g)))if(P=J[1]){if(we===9)if(j=w.getElementById(P)){if(j.id===P)return T.push(j),T}else return T;else if(he&&(j=he.getElementById(P))&&ht(w,j)&&j.id===P)return T.push(j),T}else{if(J[2])return tr.apply(T,w.getElementsByTagName(g)),T;if((P=J[3])&&n.getElementsByClassName&&w.getElementsByClassName)return tr.apply(T,w.getElementsByClassName(P)),T}if(n.qsa&&!pt[g+" "]&&(!re||!re.test(g))&&(we!==1||w.nodeName.toLowerCase()!=="object")){if(se=g,he=w,we===1&&(qo.test(g)||vs.test(g))){for(he=ta.test(g)&&ia(w.parentNode)||w,(he!==w||!n.scope)&&((Q=w.getAttribute("id"))?Q=Q.replace(bs,ys):w.setAttribute("id",Q=De)),ue=h(g),O=ue.length;O--;)ue[O]=(Q?"#"+Q:":scope")+" "+Ki(ue[O]);se=ue.join(",")}try{if(n.cssSupportsSelector&&!CSS.supports("selector(:is("+se+"))"))throw new Error;return tr.apply(T,he.querySelectorAll(se)),T}catch(Ie){pt(g,!0)}finally{Q===De&&w.removeAttribute("id")}}}return x(g.replace(Xi,"$1"),w,T,M)}function Ji(){var g=[];function w(T,M){return g.push(T+" ")>s.cacheLength&&delete w[g.shift()],w[T+" "]=M}return w}function kt(g){return g[De]=!0,g}function St(g){var w=I.createElement("fieldset");try{return!!g(w)}catch(T){return!1}finally{w.parentNode&&w.parentNode.removeChild(w),w=null}}function ra(g,w){for(var T=g.split("|"),M=T.length;M--;)s.attrHandle[T[M]]=w}function ws(g,w){var T=w&&g,M=T&&g.nodeType===1&&w.nodeType===1&&g.sourceIndex-w.sourceIndex;if(M)return M;if(T){for(;T=T.nextSibling;)if(T===w)return-1}return g?1:-1}function el(g){return function(w){var T=w.nodeName.toLowerCase();return T==="input"&&w.type===g}}function tl(g){return function(w){var T=w.nodeName.toLowerCase();return(T==="input"||T==="button")&&w.type===g}}function Es(g){return function(w){return"form"in w?w.parentNode&&w.disabled===!1?"label"in w?"label"in w.parentNode?w.parentNode.disabled===g:w.disabled===g:w.isDisabled===g||w.isDisabled!==!g&&Zo(w)===g:w.disabled===g:"label"in w?w.disabled===g:!1}}function mr(g){return kt(function(w){return w=+w,kt(function(T,M){for(var P,O=g([],T.length,w),j=O.length;j--;)T[P=O[j]]&&(T[P]=!(M[P]=T[P]))})})}function ia(g){return g&&typeof g.getElementsByTagName!="undefined"&&g}n=Re.support={},f=Re.isXML=function(g){var w=g&&g.namespaceURI,T=g&&(g.ownerDocument||g).documentElement;return!Xo.test(w||T&&T.nodeName||"HTML")},F=Re.setDocument=function(g){var w,T,M=g?g.ownerDocument||g:me;return M==I||M.nodeType!==9||!M.documentElement||(I=M,ie=I.documentElement,ve=!f(I),me!=I&&(T=I.defaultView)&&T.top!==T&&(T.addEventListener?T.addEventListener("unload",xs,!1):T.attachEvent&&T.attachEvent("onunload",xs)),n.scope=St(function(P){return ie.appendChild(P).appendChild(I.createElement("div")),typeof P.querySelectorAll!="undefined"&&!P.querySelectorAll(":scope fieldset div").length}),n.cssSupportsSelector=St(function(){return CSS.supports("selector(*)")&&I.querySelectorAll(":is(:jqfake)")&&!CSS.supports("selector(:is(*,:jqfake))")}),n.attributes=St(function(P){return P.className="i",!P.getAttribute("className")}),n.getElementsByTagName=St(function(P){return P.appendChild(I.createComment("")),!P.getElementsByTagName("*").length}),n.getElementsByClassName=ai.test(I.getElementsByClassName),n.getById=St(function(P){return ie.appendChild(P).id=De,!I.getElementsByName||!I.getElementsByName(De).length}),n.getById?(s.filter.ID=function(P){var O=P.replace(zt,Vt);return function(j){return j.getAttribute("id")===O}},s.find.ID=function(P,O){if(typeof O.getElementById!="undefined"&&ve){var j=O.getElementById(P);return j?[j]:[]}}):(s.filter.ID=function(P){var O=P.replace(zt,Vt);return function(j){var Q=typeof j.getAttributeNode!="undefined"&&j.getAttributeNode("id");return Q&&Q.value===O}},s.find.ID=function(P,O){if(typeof O.getElementById!="undefined"&&ve){var j,Q,J,ue=O.getElementById(P);if(ue){if(j=ue.getAttributeNode("id"),j&&j.value===P)return[ue];for(J=O.getElementsByName(P),Q=0;ue=J[Q++];)if(j=ue.getAttributeNode("id"),j&&j.value===P)return[ue]}return[]}}),s.find.TAG=n.getElementsByTagName?function(P,O){if(typeof O.getElementsByTagName!="undefined")return O.getElementsByTagName(P);if(n.qsa)return O.querySelectorAll(P)}:function(P,O){var j,Q=[],J=0,ue=O.getElementsByTagName(P);if(P==="*"){for(;j=ue[J++];)j.nodeType===1&&Q.push(j);return Q}return ue},s.find.CLASS=n.getElementsByClassName&&function(P,O){if(typeof O.getElementsByClassName!="undefined"&&ve)return O.getElementsByClassName(P)},qe=[],re=[],(n.qsa=ai.test(I.querySelectorAll))&&(St(function(P){var O;ie.appendChild(P).innerHTML="",P.querySelectorAll("[msallowcapture^='']").length&&re.push("[*^$]="+Ae+`*(?:''|"")`),P.querySelectorAll("[selected]").length||re.push("\\["+Ae+"*(?:value|"+Zn+")"),P.querySelectorAll("[id~="+De+"-]").length||re.push("~="),O=I.createElement("input"),O.setAttribute("name",""),P.appendChild(O),P.querySelectorAll("[name='']").length||re.push("\\["+Ae+"*name"+Ae+"*="+Ae+`*(?:''|"")`),P.querySelectorAll(":checked").length||re.push(":checked"),P.querySelectorAll("a#"+De+"+*").length||re.push(".#.+[+~]"),P.querySelectorAll("\\\f"),re.push("[\\r\\n\\f]")}),St(function(P){P.innerHTML="";var O=I.createElement("input");O.setAttribute("type","hidden"),P.appendChild(O).setAttribute("name","D"),P.querySelectorAll("[name=d]").length&&re.push("name"+Ae+"*[*^$|!~]?="),P.querySelectorAll(":enabled").length!==2&&re.push(":enabled",":disabled"),ie.appendChild(P).disabled=!0,P.querySelectorAll(":disabled").length!==2&&re.push(":enabled",":disabled"),P.querySelectorAll("*,:x"),re.push(",.*:")})),(n.matchesSelector=ai.test(Ve=ie.matches||ie.webkitMatchesSelector||ie.mozMatchesSelector||ie.oMatchesSelector||ie.msMatchesSelector))&&St(function(P){n.disconnectedMatch=Ve.call(P,"*"),Ve.call(P,"[s!='']:x"),qe.push("!=",ea)}),n.cssSupportsSelector||re.push(":has"),re=re.length&&new RegExp(re.join("|")),qe=qe.length&&new RegExp(qe.join("|")),w=ai.test(ie.compareDocumentPosition),ht=w||ai.test(ie.contains)?function(P,O){var j=P.nodeType===9&&P.documentElement||P,Q=O&&O.parentNode;return P===Q||!!(Q&&Q.nodeType===1&&(j.contains?j.contains(Q):P.compareDocumentPosition&&P.compareDocumentPosition(Q)&16))}:function(P,O){if(O){for(;O=O.parentNode;)if(O===P)return!0}return!1},dr=w?function(P,O){if(P===O)return U=!0,0;var j=!P.compareDocumentPosition-!O.compareDocumentPosition;return j||(j=(P.ownerDocument||P)==(O.ownerDocument||O)?P.compareDocumentPosition(O):1,j&1||!n.sortDetached&&O.compareDocumentPosition(P)===j?P==I||P.ownerDocument==me&&ht(me,P)?-1:O==I||O.ownerDocument==me&&ht(me,O)?1:R?pr(R,P)-pr(R,O):0:j&4?-1:1)}:function(P,O){if(P===O)return U=!0,0;var j,Q=0,J=P.parentNode,ue=O.parentNode,se=[P],he=[O];if(!J||!ue)return P==I?-1:O==I?1:J?-1:ue?1:R?pr(R,P)-pr(R,O):0;if(J===ue)return ws(P,O);for(j=P;j=j.parentNode;)se.unshift(j);for(j=O;j=j.parentNode;)he.unshift(j);for(;se[Q]===he[Q];)Q++;return Q?ws(se[Q],he[Q]):se[Q]==me?-1:he[Q]==me?1:0}),I},Re.matches=function(g,w){return Re(g,null,null,w)},Re.matchesSelector=function(g,w){if(F(g),n.matchesSelector&&ve&&!pt[w+" "]&&(!qe||!qe.test(w))&&(!re||!re.test(w)))try{var T=Ve.call(g,w);if(T||n.disconnectedMatch||g.document&&g.document.nodeType!==11)return T}catch(M){pt(w,!0)}return Re(w,I,null,[g]).length>0},Re.contains=function(g,w){return(g.ownerDocument||g)!=I&&F(g),ht(g,w)},Re.attr=function(g,w){(g.ownerDocument||g)!=I&&F(g);var T=s.attrHandle[w.toLowerCase()],M=T&&hr.call(s.attrHandle,w.toLowerCase())?T(g,w,!ve):void 0;return M!==void 0?M:n.attributes||!ve?g.getAttribute(w):(M=g.getAttributeNode(w))&&M.specified?M.value:null},Re.escape=function(g){return(g+"").replace(bs,ys)},Re.error=function(g){throw new Error("Syntax error, unrecognized expression: "+g)},Re.uniqueSort=function(g){var w,T=[],M=0,P=0;if(U=!n.detectDuplicates,R=!n.sortStable&&g.slice(0),g.sort(dr),U){for(;w=g[P++];)w===g[P]&&(M=T.push(P));for(;M--;)g.splice(T[M],1)}return R=null,g},c=Re.getText=function(g){var w,T="",M=0,P=g.nodeType;if(P){if(P===1||P===9||P===11){if(typeof g.textContent=="string")return g.textContent;for(g=g.firstChild;g;g=g.nextSibling)T+=c(g)}else if(P===3||P===4)return g.nodeValue}else for(;w=g[M++];)T+=c(w);return T},s=Re.selectors={cacheLength:50,createPseudo:kt,match:Qi,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(g){return g[1]=g[1].replace(zt,Vt),g[3]=(g[3]||g[4]||g[5]||"").replace(zt,Vt),g[2]==="~="&&(g[3]=" "+g[3]+" "),g.slice(0,4)},CHILD:function(g){return g[1]=g[1].toLowerCase(),g[1].slice(0,3)==="nth"?(g[3]||Re.error(g[0]),g[4]=+(g[4]?g[5]+(g[6]||1):2*(g[3]==="even"||g[3]==="odd")),g[5]=+(g[7]+g[8]||g[3]==="odd")):g[3]&&Re.error(g[0]),g},PSEUDO:function(g){var w,T=!g[6]&&g[2];return Qi.CHILD.test(g[0])?null:(g[3]?g[2]=g[4]||g[5]||"":T&&Go.test(T)&&(w=h(T,!0))&&(w=T.indexOf(")",T.length-w)-T.length)&&(g[0]=g[0].slice(0,w),g[2]=T.slice(0,w)),g.slice(0,3))}},filter:{TAG:function(g){var w=g.replace(zt,Vt).toLowerCase();return g==="*"?function(){return!0}:function(T){return T.nodeName&&T.nodeName.toLowerCase()===w}},CLASS:function(g){var w=Be[g+" "];return w||(w=new RegExp("(^|"+Ae+")"+g+"("+Ae+"|$)"))&&Be(g,function(T){return w.test(typeof T.className=="string"&&T.className||typeof T.getAttribute!="undefined"&&T.getAttribute("class")||"")})},ATTR:function(g,w,T){return function(M){var P=Re.attr(M,g);return P==null?w==="!=":w?(P+="",w==="="?P===T:w==="!="?P!==T:w==="^="?T&&P.indexOf(T)===0:w==="*="?T&&P.indexOf(T)>-1:w==="$="?T&&P.slice(-T.length)===T:w==="~="?(" "+P.replace(zo," ")+" ").indexOf(T)>-1:w==="|="?P===T||P.slice(0,T.length+1)===T+"-":!1):!0}},CHILD:function(g,w,T,M,P){var O=g.slice(0,3)!=="nth",j=g.slice(-4)!=="last",Q=w==="of-type";return M===1&&P===0?function(J){return!!J.parentNode}:function(J,ue,se){var he,we,Ie,ce,Ge,rt,gt=O!==j?"nextSibling":"previousSibling",Ne=J.parentNode,si=Q&&J.nodeName.toLowerCase(),oi=!se&&!Q,mt=!1;if(Ne){if(O){for(;gt;){for(ce=J;ce=ce[gt];)if(Q?ce.nodeName.toLowerCase()===si:ce.nodeType===1)return!1;rt=gt=g==="only"&&!rt&&"nextSibling"}return!0}if(rt=[j?Ne.firstChild:Ne.lastChild],j&&oi){for(ce=Ne,Ie=ce[De]||(ce[De]={}),we=Ie[ce.uniqueID]||(Ie[ce.uniqueID]={}),he=we[g]||[],Ge=he[0]===ut&&he[1],mt=Ge&&he[2],ce=Ge&&Ne.childNodes[Ge];ce=++Ge&&ce&&ce[gt]||(mt=Ge=0)||rt.pop();)if(ce.nodeType===1&&++mt&&ce===J){we[g]=[ut,Ge,mt];break}}else if(oi&&(ce=J,Ie=ce[De]||(ce[De]={}),we=Ie[ce.uniqueID]||(Ie[ce.uniqueID]={}),he=we[g]||[],Ge=he[0]===ut&&he[1],mt=Ge),mt===!1)for(;(ce=++Ge&&ce&&ce[gt]||(mt=Ge=0)||rt.pop())&&!((Q?ce.nodeName.toLowerCase()===si:ce.nodeType===1)&&++mt&&(oi&&(Ie=ce[De]||(ce[De]={}),we=Ie[ce.uniqueID]||(Ie[ce.uniqueID]={}),we[g]=[ut,mt]),ce===J)););return mt-=P,mt===M||mt%M==0&&mt/M>=0}}},PSEUDO:function(g,w){var T,M=s.pseudos[g]||s.setFilters[g.toLowerCase()]||Re.error("unsupported pseudo: "+g);return M[De]?M(w):M.length>1?(T=[g,g,"",w],s.setFilters.hasOwnProperty(g.toLowerCase())?kt(function(P,O){for(var j,Q=M(P,w),J=Q.length;J--;)j=pr(P,Q[J]),P[j]=!(O[j]=Q[J])}):function(P){return M(P,0,T)}):M}},pseudos:{not:kt(function(g){var w=[],T=[],M=E(g.replace(Xi,"$1"));return M[De]?kt(function(P,O,j,Q){for(var J,ue=M(P,null,Q,[]),se=P.length;se--;)(J=ue[se])&&(P[se]=!(O[se]=J))}):function(P,O,j){return w[0]=P,M(w,null,j,T),w[0]=null,!T.pop()}}),has:kt(function(g){return function(w){return Re(g,w).length>0}}),contains:kt(function(g){return g=g.replace(zt,Vt),function(w){return(w.textContent||c(w)).indexOf(g)>-1}}),lang:kt(function(g){return Yo.test(g||"")||Re.error("unsupported lang: "+g),g=g.replace(zt,Vt).toLowerCase(),function(w){var T;do if(T=ve?w.lang:w.getAttribute("xml:lang")||w.getAttribute("lang"))return T=T.toLowerCase(),T===g||T.indexOf(g+"-")===0;while((w=w.parentNode)&&w.nodeType===1);return!1}}),target:function(g){var w=e.location&&e.location.hash;return w&&w.slice(1)===g.id},root:function(g){return g===ie},focus:function(g){return g===I.activeElement&&(!I.hasFocus||I.hasFocus())&&!!(g.type||g.href||~g.tabIndex)},enabled:Es(!1),disabled:Es(!0),checked:function(g){var w=g.nodeName.toLowerCase();return w==="input"&&!!g.checked||w==="option"&&!!g.selected},selected:function(g){return g.parentNode&&g.parentNode.selectedIndex,g.selected===!0},empty:function(g){for(g=g.firstChild;g;g=g.nextSibling)if(g.nodeType<6)return!1;return!0},parent:function(g){return!s.pseudos.empty(g)},header:function(g){return Jo.test(g.nodeName)},input:function(g){return Qo.test(g.nodeName)},button:function(g){var w=g.nodeName.toLowerCase();return w==="input"&&g.type==="button"||w==="button"},text:function(g){var w;return g.nodeName.toLowerCase()==="input"&&g.type==="text"&&((w=g.getAttribute("type"))==null||w.toLowerCase()==="text")},first:mr(function(){return[0]}),last:mr(function(g,w){return[w-1]}),eq:mr(function(g,w,T){return[T<0?T+w:T]}),even:mr(function(g,w){for(var T=0;Tw?w:T;--M>=0;)g.push(M);return g}),gt:mr(function(g,w,T){for(var M=T<0?T+w:T;++M1?function(w,T,M){for(var P=g.length;P--;)if(!g[P](w,T,M))return!1;return!0}:g[0]}function rl(g,w,T){for(var M=0,P=w.length;M-1&&(j[se]=!(Q[se]=we))}}else Ne=en(Ne===Q?Ne.splice(Ge,Ne.length):Ne),P?P(null,Q,Ne,ue):tr.apply(Q,Ne)})}function sa(g){for(var w,T,M,P=g.length,O=s.relative[g[0].type],j=O||s.relative[" "],Q=O?1:0,J=Zi(function(he){return he===w},j,!0),ue=Zi(function(he){return pr(w,he)>-1},j,!0),se=[function(he,we,Ie){var ce=!O&&(Ie||we!==D)||((w=we).nodeType?J(he,we,Ie):ue(he,we,Ie));return w=null,ce}];Q1&&na(se),Q>1&&Ki(g.slice(0,Q-1).concat({value:g[Q-2].type===" "?"*":""})).replace(Xi,"$1"),T,Q0,M=g.length>0,P=function(O,j,Q,J,ue){var se,he,we,Ie=0,ce="0",Ge=O&&[],rt=[],gt=D,Ne=O||M&&s.find.TAG("*",ue),si=ut+=gt==null?1:Math.random()||.1,oi=Ne.length;for(ue&&(D=j==I||j||ue);ce!==oi&&(se=Ne[ce])!=null;ce++){if(M&&se){for(he=0,!j&&se.ownerDocument!=I&&(F(se),Q=!ve);we=g[he++];)if(we(se,j||I,Q)){J.push(se);break}ue&&(ut=si)}T&&((se=!we&&se)&&Ie--,O&&Ge.push(se))}if(Ie+=ce,T&&ce!==Ie){for(he=0;we=w[he++];)we(Ge,rt,j,Q);if(O){if(Ie>0)for(;ce--;)Ge[ce]||rt[ce]||(rt[ce]=er.call(J));rt=en(rt)}tr.apply(J,rt),ue&&!O&&rt.length>0&&Ie+w.length>1&&Re.uniqueSort(J)}return ue&&(ut=si,D=gt),Ge};return T?kt(P):P}return E=Re.compile=function(g,w){var T,M=[],P=[],O=Yi[g+" "];if(!O){for(w||(w=h(g)),T=w.length;T--;)O=sa(w[T]),O[De]?M.push(O):P.push(O);O=Yi(g,il(P,M)),O.selector=g}return O},x=Re.select=function(g,w,T,M){var P,O,j,Q,J,ue=typeof g=="function"&&g,se=!M&&h(g=ue.selector||g);if(T=T||[],se.length===1){if(O=se[0]=se[0].slice(0),O.length>2&&(j=O[0]).type==="ID"&&w.nodeType===9&&ve&&s.relative[O[1].type]){if(w=(s.find.ID(j.matches[0].replace(zt,Vt),w)||[])[0],w)ue&&(w=w.parentNode);else return T;g=g.slice(O.shift().value.length)}for(P=Qi.needsContext.test(g)?0:O.length;P--&&(j=O[P],!s.relative[Q=j.type]);)if((J=s.find[Q])&&(M=J(j.matches[0].replace(zt,Vt),ta.test(O[0].type)&&ia(w.parentNode)||w))){if(O.splice(P,1),g=M.length&&Ki(O),!g)return tr.apply(T,M),T;break}}return(ue||E(g,se))(M,w,!ve,T,!w||ta.test(g)&&ia(w.parentNode)||w),T},n.sortStable=De.split("").sort(dr).join("")===De,n.detectDuplicates=!!U,F(),n.sortDetached=St(function(g){return g.compareDocumentPosition(I.createElement("fieldset"))&1}),St(function(g){return g.innerHTML="",g.firstChild.getAttribute("href")==="#"})||ra("type|href|height|width",function(g,w,T){if(!T)return g.getAttribute(w,w.toLowerCase()==="type"?1:2)}),(!n.attributes||!St(function(g){return g.innerHTML="",g.firstChild.setAttribute("value",""),g.firstChild.getAttribute("value")===""}))&&ra("value",function(g,w,T){if(!T&&g.nodeName.toLowerCase()==="input")return g.defaultValue}),St(function(g){return g.getAttribute("disabled")==null})||ra(Zn,function(g,w,T){var M;if(!T)return g[w]===!0?w.toLowerCase():(M=g.getAttributeNode(w))&&M.specified?M.value:null}),Re}(l);o.find=ae,o.expr=ae.selectors,o.expr[":"]=o.expr.pseudos,o.uniqueSort=o.unique=ae.uniqueSort,o.text=ae.getText,o.isXMLDoc=ae.isXML,o.contains=ae.contains,o.escapeSelector=ae.escape;var oe=function(e,i,n){for(var s=[],c=n!==void 0;(e=e[i])&&e.nodeType!==9;)if(e.nodeType===1){if(c&&o(e).is(n))break;s.push(e)}return s},_e=function(e,i){for(var n=[];e;e=e.nextSibling)e.nodeType===1&&e!==i&&n.push(e);return n},ze=o.expr.match.needsContext;function Me(e,i){return e.nodeName&&e.nodeName.toLowerCase()===i.toLowerCase()}var nt=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function Ke(e,i,n){return V(i)?o.grep(e,function(s,c){return!!i.call(s,c,s)!==n}):i.nodeType?o.grep(e,function(s){return s===i!==n}):typeof i!="string"?o.grep(e,function(s){return b.call(i,s)>-1!==n}):o.filter(i,e,n)}o.filter=function(e,i,n){var s=i[0];return n&&(e=":not("+e+")"),i.length===1&&s.nodeType===1?o.find.matchesSelector(s,e)?[s]:[]:o.find.matches(e,o.grep(i,function(c){return c.nodeType===1}))},o.fn.extend({find:function(e){var i,n,s=this.length,c=this;if(typeof e!="string")return this.pushStack(o(e).filter(function(){for(i=0;i1?o.uniqueSort(n):n},filter:function(e){return this.pushStack(Ke(this,e||[],!1))},not:function(e){return this.pushStack(Ke(this,e||[],!0))},is:function(e){return!!Ke(this,typeof e=="string"&&ze.test(e)?o(e):e||[],!1).length}});var bt,nr=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,Sr=o.fn.init=function(e,i,n){var s,c;if(!e)return this;if(n=n||bt,typeof e=="string")if(e[0]==="<"&&e[e.length-1]===">"&&e.length>=3?s=[null,e,null]:s=nr.exec(e),s&&(s[1]||!i))if(s[1]){if(i=i instanceof o?i[0]:i,o.merge(this,o.parseHTML(s[1],i&&i.nodeType?i.ownerDocument||i:K,!0)),nt.test(s[1])&&o.isPlainObject(i))for(s in i)V(this[s])?this[s](i[s]):this.attr(s,i[s]);return this}else return c=K.getElementById(s[2]),c&&(this[0]=c,this.length=1),this;else return!i||i.jquery?(i||n).find(e):this.constructor(i).find(e);else{if(e.nodeType)return this[0]=e,this.length=1,this;if(V(e))return n.ready!==void 0?n.ready(e):e(o)}return o.makeArray(e,this)};Sr.prototype=o.fn,bt=o(K);var Nr=/^(?:parents|prev(?:Until|All))/,Qt={children:!0,contents:!0,next:!0,prev:!0};o.fn.extend({has:function(e){var i=o(e,this),n=i.length;return this.filter(function(){for(var s=0;s-1:n.nodeType===1&&o.find.matchesSelector(n,e))){f.push(n);break}}return this.pushStack(f.length>1?o.uniqueSort(f):f)},index:function(e){return e?typeof e=="string"?b.call(o(e),this[0]):b.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,i){return this.pushStack(o.uniqueSort(o.merge(this.get(),o(e,i))))},addBack:function(e){return this.add(e==null?this.prevObject:this.prevObject.filter(e))}});function Or(e,i){for(;(e=e[i])&&e.nodeType!==1;);return e}o.each({parent:function(e){var i=e.parentNode;return i&&i.nodeType!==11?i:null},parents:function(e){return oe(e,"parentNode")},parentsUntil:function(e,i,n){return oe(e,"parentNode",n)},next:function(e){return Or(e,"nextSibling")},prev:function(e){return Or(e,"previousSibling")},nextAll:function(e){return oe(e,"nextSibling")},prevAll:function(e){return oe(e,"previousSibling")},nextUntil:function(e,i,n){return oe(e,"nextSibling",n)},prevUntil:function(e,i,n){return oe(e,"previousSibling",n)},siblings:function(e){return _e((e.parentNode||{}).firstChild,e)},children:function(e){return _e(e.firstChild)},contents:function(e){return e.contentDocument!=null&&a(e.contentDocument)?e.contentDocument:(Me(e,"template")&&(e=e.content||e),o.merge([],e.childNodes))}},function(e,i){o.fn[e]=function(n,s){var c=o.map(this,i,n);return e.slice(-5)!=="Until"&&(s=n),s&&typeof s=="string"&&(c=o.filter(s,c)),this.length>1&&(Qt[e]||o.uniqueSort(c),Nr.test(e)&&c.reverse()),this.pushStack(c)}});var yt=/[^\x20\t\r\n\f]+/g;function Ln(e){var i={};return o.each(e.match(yt)||[],function(n,s){i[s]=!0}),i}o.Callbacks=function(e){e=typeof e=="string"?Ln(e):o.extend({},e);var i,n,s,c,f=[],h=[],E=-1,x=function(){for(c=c||e.once,s=i=!0;h.length;E=-1)for(n=h.shift();++E-1;)f.splice(F,1),F<=E&&E--}),this},has:function(R){return R?o.inArray(R,f)>-1:f.length>0},empty:function(){return f&&(f=[]),this},disable:function(){return c=h=[],f=n="",this},disabled:function(){return!f},lock:function(){return c=h=[],!n&&!i&&(f=n=""),this},locked:function(){return!!c},fireWith:function(R,U){return c||(U=U||[],U=[R,U.slice?U.slice():U],h.push(U),i||x()),this},fire:function(){return D.fireWith(this,arguments),this},fired:function(){return!!s}};return D};function Ze(e){return e}function ar(e){throw e}function Di(e,i,n,s){var c;try{e&&V(c=e.promise)?c.call(e).done(i).fail(n):e&&V(c=e.then)?c.call(e,i,n):i.apply(void 0,[e].slice(s))}catch(f){n.apply(void 0,[f])}}o.extend({Deferred:function(e){var i=[["notify","progress",o.Callbacks("memory"),o.Callbacks("memory"),2],["resolve","done",o.Callbacks("once memory"),o.Callbacks("once memory"),0,"resolved"],["reject","fail",o.Callbacks("once memory"),o.Callbacks("once memory"),1,"rejected"]],n="pending",s={state:function(){return n},always:function(){return c.done(arguments).fail(arguments),this},catch:function(f){return s.then(null,f)},pipe:function(){var f=arguments;return o.Deferred(function(h){o.each(i,function(E,x){var D=V(f[x[4]])&&f[x[4]];c[x[1]](function(){var R=D&&D.apply(this,arguments);R&&V(R.promise)?R.promise().progress(h.notify).done(h.resolve).fail(h.reject):h[x[0]+"With"](this,D?[R]:arguments)})}),f=null}).promise()},then:function(f,h,E){var x=0;function D(R,U,F,I){return function(){var ie=this,ve=arguments,re=function(){var Ve,ht;if(!(R=x&&(F!==ar&&(ie=void 0,ve=[Ve]),U.rejectWith(ie,ve))}};R?qe():(o.Deferred.getStackHook&&(qe.stackTrace=o.Deferred.getStackHook()),l.setTimeout(qe))}}return o.Deferred(function(R){i[0][3].add(D(0,R,V(E)?E:Ze,R.notifyWith)),i[1][3].add(D(0,R,V(f)?f:Ze)),i[2][3].add(D(0,R,V(h)?h:ar))}).promise()},promise:function(f){return f!=null?o.extend(f,s):s}},c={};return o.each(i,function(f,h){var E=h[2],x=h[5];s[h[1]]=E.add,x&&E.add(function(){n=x},i[3-f][2].disable,i[3-f][3].disable,i[0][2].lock,i[0][3].lock),E.add(h[3].fire),c[h[0]]=function(){return c[h[0]+"With"](this===c?void 0:this,arguments),this},c[h[0]+"With"]=E.fireWith}),s.promise(c),e&&e.call(c,c),c},when:function(e){var i=arguments.length,n=i,s=Array(n),c=u.call(arguments),f=o.Deferred(),h=function(E){return function(x){s[E]=this,c[E]=arguments.length>1?u.call(arguments):x,--i||f.resolveWith(s,c)}};if(i<=1&&(Di(e,f.done(h(n)).resolve,f.reject,!i),f.state()==="pending"||V(c[n]&&c[n].then)))return f.then();for(;n--;)Di(c[n],h(n),f.reject);return f.promise()}});var Fn=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;o.Deferred.exceptionHook=function(e,i){l.console&&l.console.warn&&e&&Fn.test(e.name)&&l.console.warn("jQuery.Deferred exception: "+e.message,e.stack,i)},o.readyException=function(e){l.setTimeout(function(){throw e})};var $r=o.Deferred();o.fn.ready=function(e){return $r.then(e).catch(function(i){o.readyException(i)}),this},o.extend({isReady:!1,readyWait:1,ready:function(e){(e===!0?--o.readyWait:o.isReady)||(o.isReady=!0,!(e!==!0&&--o.readyWait>0)&&$r.resolveWith(K,[o]))}}),o.ready.then=$r.then;function _r(){K.removeEventListener("DOMContentLoaded",_r),l.removeEventListener("load",_r),o.ready()}K.readyState==="complete"||K.readyState!=="loading"&&!K.documentElement.doScroll?l.setTimeout(o.ready):(K.addEventListener("DOMContentLoaded",_r),l.addEventListener("load",_r));var Ct=function(e,i,n,s,c,f,h){var E=0,x=e.length,D=n==null;if(be(n)==="object"){c=!0;for(E in n)Ct(e,i,E,n[E],!0,f,h)}else if(s!==void 0&&(c=!0,V(s)||(h=!0),D&&(h?(i.call(e,s),i=null):(D=i,i=function(R,U,F){return D.call(o(R),F)})),i))for(;E1,null,!0)},removeData:function(e){return this.each(function(){$e.remove(this,e)})}}),o.extend({queue:function(e,i,n){var s;if(e)return i=(i||"fx")+"queue",s=le.get(e,i),n&&(!s||Array.isArray(n)?s=le.access(e,i,o.makeArray(n)):s.push(n)),s||[]},dequeue:function(e,i){i=i||"fx";var n=o.queue(e,i),s=n.length,c=n.shift(),f=o._queueHooks(e,i),h=function(){o.dequeue(e,i)};c==="inprogress"&&(c=n.shift(),s--),c&&(i==="fx"&&n.unshift("inprogress"),delete f.stop,c.call(e,h,f)),!s&&f&&f.empty.fire()},_queueHooks:function(e,i){var n=i+"queueHooks";return le.get(e,n)||le.access(e,n,{empty:o.Callbacks("once memory").add(function(){le.remove(e,[i+"queue",n])})})}}),o.fn.extend({queue:function(e,i){var n=2;return typeof e!="string"&&(i=e,e="fx",n--),arguments.length\x20\t\r\n\f]*)/i,jr=/^$|^module$|\/(?:java|ecma)script/i;(function(){var e=K.createDocumentFragment(),i=e.appendChild(K.createElement("div")),n=K.createElement("input");n.setAttribute("type","radio"),n.setAttribute("checked","checked"),n.setAttribute("name","t"),i.appendChild(n),H.checkClone=i.cloneNode(!0).cloneNode(!0).lastChild.checked,i.innerHTML="",H.noCloneChecked=!!i.cloneNode(!0).lastChild.defaultValue,i.innerHTML="",H.option=!!i.lastChild})();var et={thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};et.tbody=et.tfoot=et.colgroup=et.caption=et.thead,et.th=et.td,H.option||(et.optgroup=et.option=[1,""]);function tt(e,i){var n;return typeof e.getElementsByTagName!="undefined"?n=e.getElementsByTagName(i||"*"):typeof e.querySelectorAll!="undefined"?n=e.querySelectorAll(i||"*"):n=[],i===void 0||i&&Me(e,i)?o.merge([e],n):n}function Hr(e,i){for(var n=0,s=e.length;n-1){c&&c.push(f);continue}if(D=Wt(f),h=tt(U.appendChild(f),"script"),D&&Hr(h),n)for(R=0;f=h[R++];)jr.test(f.type||"")&&n.push(f)}return U}var Ii=/^([^.]*)(?:\.(.+)|)/;function at(){return!0}function Kt(){return!1}function On(e,i){return e===Mi()==(i==="focus")}function Mi(){try{return K.activeElement}catch(e){}}function qr(e,i,n,s,c,f){var h,E;if(typeof i=="object"){typeof n!="string"&&(s=s||n,n=void 0);for(E in i)qr(e,E,n,s,i[E],f);return e}if(s==null&&c==null?(c=n,s=n=void 0):c==null&&(typeof n=="string"?(c=s,s=void 0):(c=s,s=n,n=void 0)),c===!1)c=Kt;else if(!c)return e;return f===1&&(h=c,c=function(x){return o().off(x),h.apply(this,arguments)},c.guid=h.guid||(h.guid=o.guid++)),e.each(function(){o.event.add(this,i,c,s,n)})}o.event={global:{},add:function(e,i,n,s,c){var f,h,E,x,D,R,U,F,I,ie,ve,re=le.get(e);if(!!sr(e))for(n.handler&&(f=n,n=f.handler,c=f.selector),c&&o.find.matchesSelector(Lt,c),n.guid||(n.guid=o.guid++),(x=re.events)||(x=re.events=Object.create(null)),(h=re.handle)||(h=re.handle=function(qe){return typeof o!="undefined"&&o.event.triggered!==qe.type?o.event.dispatch.apply(e,arguments):void 0}),i=(i||"").match(yt)||[""],D=i.length;D--;)E=Ii.exec(i[D])||[],I=ve=E[1],ie=(E[2]||"").split(".").sort(),!!I&&(U=o.event.special[I]||{},I=(c?U.delegateType:U.bindType)||I,U=o.event.special[I]||{},R=o.extend({type:I,origType:ve,data:s,handler:n,guid:n.guid,selector:c,needsContext:c&&o.expr.match.needsContext.test(c),namespace:ie.join(".")},f),(F=x[I])||(F=x[I]=[],F.delegateCount=0,(!U.setup||U.setup.call(e,s,ie,h)===!1)&&e.addEventListener&&e.addEventListener(I,h)),U.add&&(U.add.call(e,R),R.handler.guid||(R.handler.guid=n.guid)),c?F.splice(F.delegateCount++,0,R):F.push(R),o.event.global[I]=!0)},remove:function(e,i,n,s,c){var f,h,E,x,D,R,U,F,I,ie,ve,re=le.hasData(e)&&le.get(e);if(!(!re||!(x=re.events))){for(i=(i||"").match(yt)||[""],D=i.length;D--;){if(E=Ii.exec(i[D])||[],I=ve=E[1],ie=(E[2]||"").split(".").sort(),!I){for(I in x)o.event.remove(e,I+i[D],n,s,!0);continue}for(U=o.event.special[I]||{},I=(s?U.delegateType:U.bindType)||I,F=x[I]||[],E=E[2]&&new RegExp("(^|\\.)"+ie.join("\\.(?:.*\\.|)")+"(\\.|$)"),h=f=F.length;f--;)R=F[f],(c||ve===R.origType)&&(!n||n.guid===R.guid)&&(!E||E.test(R.namespace))&&(!s||s===R.selector||s==="**"&&R.selector)&&(F.splice(f,1),R.selector&&F.delegateCount--,U.remove&&U.remove.call(e,R));h&&!F.length&&((!U.teardown||U.teardown.call(e,ie,re.handle)===!1)&&o.removeEvent(e,I,re.handle),delete x[I])}o.isEmptyObject(x)&&le.remove(e,"handle events")}},dispatch:function(e){var i,n,s,c,f,h,E=new Array(arguments.length),x=o.event.fix(e),D=(le.get(this,"events")||Object.create(null))[x.type]||[],R=o.event.special[x.type]||{};for(E[0]=x,i=1;i=1)){for(;D!==this;D=D.parentNode||this)if(D.nodeType===1&&!(e.type==="click"&&D.disabled===!0)){for(f=[],h={},n=0;n-1:o.find(c,this,null,[D]).length),h[c]&&f.push(s);f.length&&E.push({elem:D,handlers:f})}}return D=this,x\s*$/g;function Ni(e,i){return Me(e,"table")&&Me(i.nodeType!==11?i:i.firstChild,"tr")&&o(e).children("tbody")[0]||e}function Un(e){return e.type=(e.getAttribute("type")!==null)+"/"+e.type,e}function jn(e){return(e.type||"").slice(0,5)==="true/"?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Oi(e,i){var n,s,c,f,h,E,x;if(i.nodeType===1){if(le.hasData(e)&&(f=le.get(e),x=f.events,x)){le.remove(i,"handle events");for(c in x)for(n=0,s=x[c].length;n1&&typeof I=="string"&&!H.checkClone&&Wn.test(I))return e.each(function(ve){var re=e.eq(ve);ie&&(i[0]=I.call(this,ve,re.html())),Ut(re,i,n,s)});if(U&&(c=Vr(i,e[0].ownerDocument,!1,e,s),f=c.firstChild,c.childNodes.length===1&&(c=f),f||s)){for(h=o.map(tt(c,"script"),Un),E=h.length;R0&&Hr(h,!x&&tt(e,"script")),E},cleanData:function(e){for(var i,n,s,c=o.event.special,f=0;(n=e[f])!==void 0;f++)if(sr(n)){if(i=n[le.expando]){if(i.events)for(s in i.events)c[s]?o.event.remove(n,s):o.removeEvent(n,s,i.handle);n[le.expando]=void 0}n[$e.expando]&&(n[$e.expando]=void 0)}}}),o.fn.extend({detach:function(e){return $i(this,e,!0)},remove:function(e){return $i(this,e)},text:function(e){return Ct(this,function(i){return i===void 0?o.text(this):this.empty().each(function(){(this.nodeType===1||this.nodeType===11||this.nodeType===9)&&(this.textContent=i)})},null,e,arguments.length)},append:function(){return Ut(this,arguments,function(e){if(this.nodeType===1||this.nodeType===11||this.nodeType===9){var i=Ni(this,e);i.appendChild(e)}})},prepend:function(){return Ut(this,arguments,function(e){if(this.nodeType===1||this.nodeType===11||this.nodeType===9){var i=Ni(this,e);i.insertBefore(e,i.firstChild)}})},before:function(){return Ut(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return Ut(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},empty:function(){for(var e,i=0;(e=this[i])!=null;i++)e.nodeType===1&&(o.cleanData(tt(e,!1)),e.textContent="");return this},clone:function(e,i){return e=e==null?!1:e,i=i==null?e:i,this.map(function(){return o.clone(this,e,i)})},html:function(e){return Ct(this,function(i){var n=this[0]||{},s=0,c=this.length;if(i===void 0&&n.nodeType===1)return n.innerHTML;if(typeof i=="string"&&!$n.test(i)&&!et[(Ur.exec(i)||["",""])[1].toLowerCase()]){i=o.htmlPrefilter(i);try{for(;s=0&&(x+=Math.max(0,Math.ceil(e["offset"+i[0].toUpperCase()+i.slice(1)]-f-x-E-.5))||0),x}function fr(e,i,n){var s=Ar(e),c=!H.boxSizingReliable()||n,f=c&&o.css(e,"boxSizing",!1,s)==="border-box",h=f,E=ur(e,i,s),x="offset"+i[0].toUpperCase()+i.slice(1);if(Gr.test(E)){if(!n)return E;E="auto"}return(!H.boxSizingReliable()&&f||!H.reliableTrDimensions()&&Me(e,"tr")||E==="auto"||!parseFloat(E)&&o.css(e,"display",!1,s)==="inline")&&e.getClientRects().length&&(f=o.css(e,"boxSizing",!1,s)==="border-box",h=x in e,h&&(E=e[x])),E=parseFloat(E)||0,E+Jr(e,i,n||(f?"border":"content"),h,s,E)+"px"}o.extend({cssHooks:{opacity:{get:function(e,i){if(i){var n=ur(e,"opacity");return n===""?"1":n}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{},style:function(e,i,n,s){if(!(!e||e.nodeType===3||e.nodeType===8||!e.style)){var c,f,h,E=xt(i),x=Yr.test(i),D=e.style;if(x||(i=Xr(E)),h=o.cssHooks[i]||o.cssHooks[E],n!==void 0){if(f=typeof n,f==="string"&&(c=$t.exec(n))&&c[1]&&(n=Wr(e,i,c),f="number"),n==null||n!==n)return;f==="number"&&!x&&(n+=c&&c[3]||(o.cssNumber[E]?"":"px")),!H.clearCloneStyle&&n===""&&i.indexOf("background")===0&&(D[i]="inherit"),(!h||!("set"in h)||(n=h.set(e,n,s))!==void 0)&&(x?D.setProperty(i,n):D[i]=n)}else return h&&"get"in h&&(c=h.get(e,!1,s))!==void 0?c:D[i]}},css:function(e,i,n,s){var c,f,h,E=xt(i),x=Yr.test(i);return x||(i=Xr(E)),h=o.cssHooks[i]||o.cssHooks[E],h&&"get"in h&&(c=h.get(e,!0,n)),c===void 0&&(c=ur(e,i,s)),c==="normal"&&i in Qr&&(c=Qr[i]),n===""||n?(f=parseFloat(c),n===!0||isFinite(f)?f||0:c):c}}),o.each(["height","width"],function(e,i){o.cssHooks[i]={get:function(n,s,c){if(s)return Vi.test(o.css(n,"display"))&&(!n.getClientRects().length||!n.getBoundingClientRect().width)?Wi(n,cr,function(){return fr(n,i,c)}):fr(n,i,c)},set:function(n,s,c){var f,h=Ar(n),E=!H.scrollboxSize()&&h.position==="absolute",x=E||c,D=x&&o.css(n,"boxSizing",!1,h)==="border-box",R=c?Jr(n,i,c,D,h):0;return D&&E&&(R-=Math.ceil(n["offset"+i[0].toUpperCase()+i.slice(1)]-parseFloat(h[i])-Jr(n,i,"border",!1,h)-.5)),R&&(f=$t.exec(s))&&(f[3]||"px")!=="px"&&(n.style[i]=s,s=o.css(n,i)),jt(n,s,R)}}}),o.cssHooks.marginLeft=Ui(H.reliableMarginLeft,function(e,i){if(i)return(parseFloat(ur(e,"marginLeft"))||e.getBoundingClientRect().left-Wi(e,{marginLeft:0},function(){return e.getBoundingClientRect().left}))+"px"}),o.each({margin:"",padding:"",border:"Width"},function(e,i){o.cssHooks[e+i]={expand:function(n){for(var s=0,c={},f=typeof n=="string"?n.split(" "):[n];s<4;s++)c[e+wt[s]+i]=f[s]||f[s-2]||f[0];return c}},e!=="margin"&&(o.cssHooks[e+i].set=jt)}),o.fn.extend({css:function(e,i){return Ct(this,function(n,s,c){var f,h,E={},x=0;if(Array.isArray(s)){for(f=Ar(n),h=s.length;x1)}});function Qe(e,i,n,s,c){return new Qe.prototype.init(e,i,n,s,c)}o.Tween=Qe,Qe.prototype={constructor:Qe,init:function(e,i,n,s,c,f){this.elem=e,this.prop=n,this.easing=c||o.easing._default,this.options=i,this.start=this.now=this.cur(),this.end=s,this.unit=f||(o.cssNumber[n]?"":"px")},cur:function(){var e=Qe.propHooks[this.prop];return e&&e.get?e.get(this):Qe.propHooks._default.get(this)},run:function(e){var i,n=Qe.propHooks[this.prop];return this.options.duration?this.pos=i=o.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=i=e,this.now=(this.end-this.start)*i+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):Qe.propHooks._default.set(this),this}},Qe.prototype.init.prototype=Qe.prototype,Qe.propHooks={_default:{get:function(e){var i;return e.elem.nodeType!==1||e.elem[e.prop]!=null&&e.elem.style[e.prop]==null?e.elem[e.prop]:(i=o.css(e.elem,e.prop,""),!i||i==="auto"?0:i)},set:function(e){o.fx.step[e.prop]?o.fx.step[e.prop](e):e.elem.nodeType===1&&(o.cssHooks[e.prop]||e.elem.style[Xr(e.prop)]!=null)?o.style(e.elem,e.prop,e.now+e.unit):e.elem[e.prop]=e.now}}},Qe.propHooks.scrollTop=Qe.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},o.easing={linear:function(e){return e},swing:function(e){return .5-Math.cos(e*Math.PI)/2},_default:"swing"},o.fx=Qe.prototype.init,o.fx.step={};var Zt,Dr,Kr=/^(?:toggle|show|hide)$/,Gn=/queueHooks$/;function Zr(){Dr&&(K.hidden===!1&&l.requestAnimationFrame?l.requestAnimationFrame(Zr):l.setTimeout(Zr,o.fx.interval),o.fx.tick())}function p(){return l.setTimeout(function(){Zt=void 0}),Zt=Date.now()}function S(e,i){var n,s=0,c={height:e};for(i=i?1:0;s<4;s+=2-i)n=wt[s],c["margin"+n]=c["padding"+n]=e;return i&&(c.opacity=c.width=e),c}function v(e,i,n){for(var s,c=(_.tweeners[i]||[]).concat(_.tweeners["*"]),f=0,h=c.length;f1)},removeAttr:function(e){return this.each(function(){o.removeAttr(this,e)})}}),o.extend({attr:function(e,i,n){var s,c,f=e.nodeType;if(!(f===3||f===8||f===2)){if(typeof e.getAttribute=="undefined")return o.prop(e,i,n);if((f!==1||!o.isXMLDoc(e))&&(c=o.attrHooks[i.toLowerCase()]||(o.expr.match.bool.test(i)?N:void 0)),n!==void 0){if(n===null){o.removeAttr(e,i);return}return c&&"set"in c&&(s=c.set(e,n,i))!==void 0?s:(e.setAttribute(i,n+""),n)}return c&&"get"in c&&(s=c.get(e,i))!==null?s:(s=o.find.attr(e,i),s==null?void 0:s)}},attrHooks:{type:{set:function(e,i){if(!H.radioValue&&i==="radio"&&Me(e,"input")){var n=e.value;return e.setAttribute("type",i),n&&(e.value=n),i}}}},removeAttr:function(e,i){var n,s=0,c=i&&i.match(yt);if(c&&e.nodeType===1)for(;n=c[s++];)e.removeAttribute(n)}}),N={set:function(e,i,n){return i===!1?o.removeAttr(e,n):e.setAttribute(n,n),n}},o.each(o.expr.match.bool.source.match(/\w+/g),function(e,i){var n=B[i]||o.find.attr;B[i]=function(s,c,f){var h,E,x=c.toLowerCase();return f||(E=B[x],B[x]=h,h=n(s,c,f)!=null?x:null,B[x]=E),h}});var q=/^(?:input|select|textarea|button)$/i,G=/^(?:a|area)$/i;o.fn.extend({prop:function(e,i){return Ct(this,o.prop,e,i,arguments.length>1)},removeProp:function(e){return this.each(function(){delete this[o.propFix[e]||e]})}}),o.extend({prop:function(e,i,n){var s,c,f=e.nodeType;if(!(f===3||f===8||f===2))return(f!==1||!o.isXMLDoc(e))&&(i=o.propFix[i]||i,c=o.propHooks[i]),n!==void 0?c&&"set"in c&&(s=c.set(e,n,i))!==void 0?s:e[i]=n:c&&"get"in c&&(s=c.get(e,i))!==null?s:e[i]},propHooks:{tabIndex:{get:function(e){var i=o.find.attr(e,"tabindex");return i?parseInt(i,10):q.test(e.nodeName)||G.test(e.nodeName)&&e.href?0:-1}}},propFix:{for:"htmlFor",class:"className"}}),H.optSelected||(o.propHooks.selected={get:function(e){var i=e.parentNode;return i&&i.parentNode&&i.parentNode.selectedIndex,null},set:function(e){var i=e.parentNode;i&&(i.selectedIndex,i.parentNode&&i.parentNode.selectedIndex)}}),o.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){o.propFix[this.toLowerCase()]=this});function Y(e){var i=e.match(yt)||[];return i.join(" ")}function Z(e){return e.getAttribute&&e.getAttribute("class")||""}function ye(e){return Array.isArray(e)?e:typeof e=="string"?e.match(yt)||[]:[]}o.fn.extend({addClass:function(e){var i,n,s,c,f,h;return V(e)?this.each(function(E){o(this).addClass(e.call(this,E,Z(this)))}):(i=ye(e),i.length?this.each(function(){if(s=Z(this),n=this.nodeType===1&&" "+Y(s)+" ",n){for(f=0;f-1;)n=n.replace(" "+c+" "," ");h=Y(n),s!==h&&this.setAttribute("class",h)}}):this):this.attr("class","")},toggleClass:function(e,i){var n,s,c,f,h=typeof e,E=h==="string"||Array.isArray(e);return V(e)?this.each(function(x){o(this).toggleClass(e.call(this,x,Z(this),i),i)}):typeof i=="boolean"&&E?i?this.addClass(e):this.removeClass(e):(n=ye(e),this.each(function(){if(E)for(f=o(this),c=0;c-1)return!0;return!1}});var ke=/\r/g;o.fn.extend({val:function(e){var i,n,s,c=this[0];return arguments.length?(s=V(e),this.each(function(f){var h;this.nodeType===1&&(s?h=e.call(this,f,o(this).val()):h=e,h==null?h="":typeof h=="number"?h+="":Array.isArray(h)&&(h=o.map(h,function(E){return E==null?"":E+""})),i=o.valHooks[this.type]||o.valHooks[this.nodeName.toLowerCase()],(!i||!("set"in i)||i.set(this,h,"value")===void 0)&&(this.value=h))})):c?(i=o.valHooks[c.type]||o.valHooks[c.nodeName.toLowerCase()],i&&"get"in i&&(n=i.get(c,"value"))!==void 0?n:(n=c.value,typeof n=="string"?n.replace(ke,""):n==null?"":n)):void 0}}),o.extend({valHooks:{option:{get:function(e){var i=o.find.attr(e,"value");return i!=null?i:Y(o.text(e))}},select:{get:function(e){var i,n,s,c=e.options,f=e.selectedIndex,h=e.type==="select-one",E=h?null:[],x=h?f+1:c.length;for(f<0?s=x:s=h?f:0;s-1)&&(n=!0);return n||(e.selectedIndex=-1),f}}}}),o.each(["radio","checkbox"],function(){o.valHooks[this]={set:function(e,i){if(Array.isArray(i))return e.checked=o.inArray(o(e).val(),i)>-1}},H.checkOn||(o.valHooks[this].get=function(e){return e.getAttribute("value")===null?"on":e.value})}),H.focusin="onfocusin"in l;var Pe=/^(?:focusinfocus|focusoutblur)$/,We=function(e){e.stopPropagation()};o.extend(o.event,{trigger:function(e,i,n,s){var c,f,h,E,x,D,R,U,F=[n||K],I=W.call(e,"type")?e.type:e,ie=W.call(e,"namespace")?e.namespace.split("."):[];if(f=U=h=n=n||K,!(n.nodeType===3||n.nodeType===8)&&!Pe.test(I+o.event.triggered)&&(I.indexOf(".")>-1&&(ie=I.split("."),I=ie.shift(),ie.sort()),x=I.indexOf(":")<0&&"on"+I,e=e[o.expando]?e:new o.Event(I,typeof e=="object"&&e),e.isTrigger=s?2:3,e.namespace=ie.join("."),e.rnamespace=e.namespace?new RegExp("(^|\\.)"+ie.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,e.result=void 0,e.target||(e.target=n),i=i==null?[e]:o.makeArray(i,[e]),R=o.event.special[I]||{},!(!s&&R.trigger&&R.trigger.apply(n,i)===!1))){if(!s&&!R.noBubble&&!de(n)){for(E=R.delegateType||I,Pe.test(E+I)||(f=f.parentNode);f;f=f.parentNode)F.push(f),h=f;h===(n.ownerDocument||K)&&F.push(h.defaultView||h.parentWindow||l)}for(c=0;(f=F[c++])&&!e.isPropagationStopped();)U=f,e.type=c>1?E:R.bindType||I,D=(le.get(f,"events")||Object.create(null))[e.type]&&le.get(f,"handle"),D&&D.apply(f,i),D=x&&f[x],D&&D.apply&&sr(f)&&(e.result=D.apply(f,i),e.result===!1&&e.preventDefault());return e.type=I,!s&&!e.isDefaultPrevented()&&(!R._default||R._default.apply(F.pop(),i)===!1)&&sr(n)&&x&&V(n[I])&&!de(n)&&(h=n[x],h&&(n[x]=null),o.event.triggered=I,e.isPropagationStopped()&&U.addEventListener(I,We),n[I](),e.isPropagationStopped()&&U.removeEventListener(I,We),o.event.triggered=void 0,h&&(n[x]=h)),e.result}},simulate:function(e,i,n){var s=o.extend(new o.Event,n,{type:e,isSimulated:!0});o.event.trigger(s,null,i)}}),o.fn.extend({trigger:function(e,i){return this.each(function(){o.event.trigger(e,i,this)})},triggerHandler:function(e,i){var n=this[0];if(n)return o.event.trigger(e,i,n,!0)}}),H.focusin||o.each({focus:"focusin",blur:"focusout"},function(e,i){var n=function(s){o.event.simulate(i,s.target,o.event.fix(s))};o.event.special[i]={setup:function(){var s=this.ownerDocument||this.document||this,c=le.access(s,i);c||s.addEventListener(e,n,!0),le.access(s,i,(c||0)+1)},teardown:function(){var s=this.ownerDocument||this.document||this,c=le.access(s,i)-1;c?le.access(s,i,c):(s.removeEventListener(e,n,!0),le.remove(s,i))}}});var Fe=l.location,st={guid:Date.now()},Ht=/\?/;o.parseXML=function(e){var i,n;if(!e||typeof e!="string")return null;try{i=new l.DOMParser().parseFromString(e,"text/xml")}catch(s){}return n=i&&i.getElementsByTagName("parsererror")[0],(!i||n)&&o.error("Invalid XML: "+(n?o.map(n.childNodes,function(s){return s.textContent}).join(` +`):e)),i};var ei=/\[\]$/,qi=/\r?\n/g,ti=/^(?:submit|button|image|reset|file)$/i,us=/^(?:input|select|textarea|keygen)/i;function ri(e,i,n,s){var c;if(Array.isArray(i))o.each(i,function(f,h){n||ei.test(e)?s(e,h):ri(e+"["+(typeof h=="object"&&h!=null?f:"")+"]",h,n,s)});else if(!n&&be(i)==="object")for(c in i)ri(e+"["+c+"]",i[c],n,s);else s(e,i)}o.param=function(e,i){var n,s=[],c=function(f,h){var E=V(h)?h():h;s[s.length]=encodeURIComponent(f)+"="+encodeURIComponent(E==null?"":E)};if(e==null)return"";if(Array.isArray(e)||e.jquery&&!o.isPlainObject(e))o.each(e,function(){c(this.name,this.value)});else for(n in e)ri(n,e[n],i,c);return s.join("&")},o.fn.extend({serialize:function(){return o.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=o.prop(this,"elements");return e?o.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!o(this).is(":disabled")&&us.test(this.nodeName)&&!ti.test(e)&&(this.checked||!Jt.test(e))}).map(function(e,i){var n=o(this).val();return n==null?null:Array.isArray(n)?o.map(n,function(s){return{name:i.name,value:s.replace(qi,`\r +`)}}):{name:i.name,value:n.replace(qi,`\r +`)}}).get()}});var Yn=/%20/g,Gi=/#.*$/,Ro=/([?&])_=[^&]*/,Io=/^(.*?):[ \t]*([^\r\n]*)$/mg,Mo=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,No=/^(?:GET|HEAD)$/,Oo=/^\/\//,cs={},Xn={},fs="*/".concat("*"),Qn=K.createElement("a");Qn.href=Fe.href;function ds(e){return function(i,n){typeof i!="string"&&(n=i,i="*");var s,c=0,f=i.toLowerCase().match(yt)||[];if(V(n))for(;s=f[c++];)s[0]==="+"?(s=s.slice(1)||"*",(e[s]=e[s]||[]).unshift(n)):(e[s]=e[s]||[]).push(n)}}function hs(e,i,n,s){var c={},f=e===Xn;function h(E){var x;return c[E]=!0,o.each(e[E]||[],function(D,R){var U=R(i,n,s);if(typeof U=="string"&&!f&&!c[U])return i.dataTypes.unshift(U),h(U),!1;if(f)return!(x=U)}),x}return h(i.dataTypes[0])||!c["*"]&&h("*")}function Jn(e,i){var n,s,c=o.ajaxSettings.flatOptions||{};for(n in i)i[n]!==void 0&&((c[n]?e:s||(s={}))[n]=i[n]);return s&&o.extend(!0,e,s),e}function $o(e,i,n){for(var s,c,f,h,E=e.contents,x=e.dataTypes;x[0]==="*";)x.shift(),s===void 0&&(s=e.mimeType||i.getResponseHeader("Content-Type"));if(s){for(c in E)if(E[c]&&E[c].test(s)){x.unshift(c);break}}if(x[0]in n)f=x[0];else{for(c in n){if(!x[0]||e.converters[c+" "+x[0]]){f=c;break}h||(h=c)}f=f||h}if(f)return f!==x[0]&&x.unshift(f),n[f]}function Wo(e,i,n,s){var c,f,h,E,x,D={},R=e.dataTypes.slice();if(R[1])for(h in e.converters)D[h.toLowerCase()]=e.converters[h];for(f=R.shift();f;)if(e.responseFields[f]&&(n[e.responseFields[f]]=i),!x&&s&&e.dataFilter&&(i=e.dataFilter(i,e.dataType)),x=f,f=R.shift(),f){if(f==="*")f=x;else if(x!=="*"&&x!==f){if(h=D[x+" "+f]||D["* "+f],!h){for(c in D)if(E=c.split(" "),E[1]===f&&(h=D[x+" "+E[0]]||D["* "+E[0]],h)){h===!0?h=D[c]:D[c]!==!0&&(f=E[0],R.unshift(E[1]));break}}if(h!==!0)if(h&&e.throws)i=h(i);else try{i=h(i)}catch(U){return{state:"parsererror",error:h?U:"No conversion from "+x+" to "+f}}}}return{state:"success",data:i}}o.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Fe.href,type:"GET",isLocal:Mo.test(Fe.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":fs,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":o.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,i){return i?Jn(Jn(e,o.ajaxSettings),i):Jn(o.ajaxSettings,e)},ajaxPrefilter:ds(cs),ajaxTransport:ds(Xn),ajax:function(e,i){typeof e=="object"&&(i=e,e=void 0),i=i||{};var n,s,c,f,h,E,x,D,R,U,F=o.ajaxSetup({},i),I=F.context||F,ie=F.context&&(I.nodeType||I.jquery)?o(I):o.event,ve=o.Deferred(),re=o.Callbacks("once memory"),qe=F.statusCode||{},Ve={},ht={},De="canceled",me={readyState:0,getResponseHeader:function(Te){var Be;if(x){if(!f)for(f={};Be=Io.exec(c);)f[Be[1].toLowerCase()+" "]=(f[Be[1].toLowerCase()+" "]||[]).concat(Be[2]);Be=f[Te.toLowerCase()+" "]}return Be==null?null:Be.join(", ")},getAllResponseHeaders:function(){return x?c:null},setRequestHeader:function(Te,Be){return x==null&&(Te=ht[Te.toLowerCase()]=ht[Te.toLowerCase()]||Te,Ve[Te]=Be),this},overrideMimeType:function(Te){return x==null&&(F.mimeType=Te),this},statusCode:function(Te){var Be;if(Te)if(x)me.always(Te[me.status]);else for(Be in Te)qe[Be]=[qe[Be],Te[Be]];return this},abort:function(Te){var Be=Te||De;return n&&n.abort(Be),ut(0,Be),this}};if(ve.promise(me),F.url=((e||F.url||Fe.href)+"").replace(Oo,Fe.protocol+"//"),F.type=i.method||i.type||F.method||F.type,F.dataTypes=(F.dataType||"*").toLowerCase().match(yt)||[""],F.crossDomain==null){E=K.createElement("a");try{E.href=F.url,E.href=E.href,F.crossDomain=Qn.protocol+"//"+Qn.host!=E.protocol+"//"+E.host}catch(Te){F.crossDomain=!0}}if(F.data&&F.processData&&typeof F.data!="string"&&(F.data=o.param(F.data,F.traditional)),hs(cs,F,i,me),x)return me;D=o.event&&F.global,D&&o.active++==0&&o.event.trigger("ajaxStart"),F.type=F.type.toUpperCase(),F.hasContent=!No.test(F.type),s=F.url.replace(Gi,""),F.hasContent?F.data&&F.processData&&(F.contentType||"").indexOf("application/x-www-form-urlencoded")===0&&(F.data=F.data.replace(Yn,"+")):(U=F.url.slice(s.length),F.data&&(F.processData||typeof F.data=="string")&&(s+=(Ht.test(s)?"&":"?")+F.data,delete F.data),F.cache===!1&&(s=s.replace(Ro,"$1"),U=(Ht.test(s)?"&":"?")+"_="+st.guid+++U),F.url=s+U),F.ifModified&&(o.lastModified[s]&&me.setRequestHeader("If-Modified-Since",o.lastModified[s]),o.etag[s]&&me.setRequestHeader("If-None-Match",o.etag[s])),(F.data&&F.hasContent&&F.contentType!==!1||i.contentType)&&me.setRequestHeader("Content-Type",F.contentType),me.setRequestHeader("Accept",F.dataTypes[0]&&F.accepts[F.dataTypes[0]]?F.accepts[F.dataTypes[0]]+(F.dataTypes[0]!=="*"?", "+fs+"; q=0.01":""):F.accepts["*"]);for(R in F.headers)me.setRequestHeader(R,F.headers[R]);if(F.beforeSend&&(F.beforeSend.call(I,me,F)===!1||x))return me.abort();if(De="abort",re.add(F.complete),me.done(F.success),me.fail(F.error),n=hs(Xn,F,i,me),!n)ut(-1,"No Transport");else{if(me.readyState=1,D&&ie.trigger("ajaxSend",[me,F]),x)return me;F.async&&F.timeout>0&&(h=l.setTimeout(function(){me.abort("timeout")},F.timeout));try{x=!1,n.send(Ve,ut)}catch(Te){if(x)throw Te;ut(-1,Te)}}function ut(Te,Be,ni,Yi){var pt,dr,hr,ct,er,Et=Be;x||(x=!0,h&&l.clearTimeout(h),n=void 0,c=Yi||"",me.readyState=Te>0?4:0,pt=Te>=200&&Te<300||Te===304,ni&&(ct=$o(F,me,ni)),!pt&&o.inArray("script",F.dataTypes)>-1&&o.inArray("json",F.dataTypes)<0&&(F.converters["text script"]=function(){}),ct=Wo(F,ct,me,pt),pt?(F.ifModified&&(er=me.getResponseHeader("Last-Modified"),er&&(o.lastModified[s]=er),er=me.getResponseHeader("etag"),er&&(o.etag[s]=er)),Te===204||F.type==="HEAD"?Et="nocontent":Te===304?Et="notmodified":(Et=ct.state,dr=ct.data,hr=ct.error,pt=!hr)):(hr=Et,(Te||!Et)&&(Et="error",Te<0&&(Te=0))),me.status=Te,me.statusText=(Be||Et)+"",pt?ve.resolveWith(I,[dr,Et,me]):ve.rejectWith(I,[me,Et,hr]),me.statusCode(qe),qe=void 0,D&&ie.trigger(pt?"ajaxSuccess":"ajaxError",[me,F,pt?dr:hr]),re.fireWith(I,[me,Et]),D&&(ie.trigger("ajaxComplete",[me,F]),--o.active||o.event.trigger("ajaxStop")))}return me},getJSON:function(e,i,n){return o.get(e,i,n,"json")},getScript:function(e,i){return o.get(e,void 0,i,"script")}}),o.each(["get","post"],function(e,i){o[i]=function(n,s,c,f){return V(s)&&(f=f||c,c=s,s=void 0),o.ajax(o.extend({url:n,type:i,dataType:f,data:s,success:c},o.isPlainObject(n)&&n))}}),o.ajaxPrefilter(function(e){var i;for(i in e.headers)i.toLowerCase()==="content-type"&&(e.contentType=e.headers[i]||"")}),o._evalUrl=function(e,i,n){return o.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,converters:{"text script":function(){}},dataFilter:function(s){o.globalEval(s,i,n)}})},o.fn.extend({wrapAll:function(e){var i;return this[0]&&(V(e)&&(e=e.call(this[0])),i=o(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&i.insertBefore(this[0]),i.map(function(){for(var n=this;n.firstElementChild;)n=n.firstElementChild;return n}).append(this)),this},wrapInner:function(e){return V(e)?this.each(function(i){o(this).wrapInner(e.call(this,i))}):this.each(function(){var i=o(this),n=i.contents();n.length?n.wrapAll(e):i.append(e)})},wrap:function(e){var i=V(e);return this.each(function(n){o(this).wrapAll(i?e.call(this,n):e)})},unwrap:function(e){return this.parent(e).not("body").each(function(){o(this).replaceWith(this.childNodes)}),this}}),o.expr.pseudos.hidden=function(e){return!o.expr.pseudos.visible(e)},o.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},o.ajaxSettings.xhr=function(){try{return new l.XMLHttpRequest}catch(e){}};var Bo={0:200,1223:204},ii=o.ajaxSettings.xhr();H.cors=!!ii&&"withCredentials"in ii,H.ajax=ii=!!ii,o.ajaxTransport(function(e){var i,n;if(H.cors||ii&&!e.crossDomain)return{send:function(s,c){var f,h=e.xhr();if(h.open(e.type,e.url,e.async,e.username,e.password),e.xhrFields)for(f in e.xhrFields)h[f]=e.xhrFields[f];e.mimeType&&h.overrideMimeType&&h.overrideMimeType(e.mimeType),!e.crossDomain&&!s["X-Requested-With"]&&(s["X-Requested-With"]="XMLHttpRequest");for(f in s)h.setRequestHeader(f,s[f]);i=function(E){return function(){i&&(i=n=h.onload=h.onerror=h.onabort=h.ontimeout=h.onreadystatechange=null,E==="abort"?h.abort():E==="error"?typeof h.status!="number"?c(0,"error"):c(h.status,h.statusText):c(Bo[h.status]||h.status,h.statusText,(h.responseType||"text")!=="text"||typeof h.responseText!="string"?{binary:h.response}:{text:h.responseText},h.getAllResponseHeaders()))}},h.onload=i(),n=h.onerror=h.ontimeout=i("error"),h.onabort!==void 0?h.onabort=n:h.onreadystatechange=function(){h.readyState===4&&l.setTimeout(function(){i&&n()})},i=i("abort");try{h.send(e.hasContent&&e.data||null)}catch(E){if(i)throw E}},abort:function(){i&&i()}}}),o.ajaxPrefilter(function(e){e.crossDomain&&(e.contents.script=!1)}),o.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(e){return o.globalEval(e),e}}}),o.ajaxPrefilter("script",function(e){e.cache===void 0&&(e.cache=!1),e.crossDomain&&(e.type="GET")}),o.ajaxTransport("script",function(e){if(e.crossDomain||e.scriptAttrs){var i,n;return{send:function(s,c){i=o("