2022-02-24 18:38:36 +00:00
|
|
|
import{b as W}from"./chunk-5JXVXIWK.js";import{a as Ot}from"./chunk-5SHCNQ2O.js";import{a as H}from"./chunk-VD5NND7R.js";import{j as G,l as q,w as O,x as X,z as Y}from"./chunk-2T5IQXGX.js";import{c as w}from"./chunk-JM5NHRL4.js";import{I as b,N as E,O as T,R as v,S as L,U as u,W as V,X as B,g as I,m as k}from"./chunk-VOKPYVET.js";import{c as x}from"./chunk-5XVCUSSZ.js";var F=x((Gt,U)=>{var S=function(){this.state=new Array(8);for(var t=0;t<this.state.length;t++)this.state[t]=64};S.BUTTON_A=0;S.BUTTON_B=1;S.BUTTON_SELECT=2;S.BUTTON_START=3;S.BUTTON_UP=4;S.BUTTON_DOWN=5;S.BUTTON_LEFT=6;S.BUTTON_RIGHT=7;S.prototype={buttonDown:function(t){this.state[t]=65},buttonUp:function(t){this.state[t]=64}};U.exports=S});var N=x((wt,Z)=>{Z.exports={copyArrayElements:function(t,i,e,s,n){for(var a=0;a<n;++a)e[s+a]=t[i+a]},copyArray:function(t){return t.slice(0)},fromJSON:function(t,i){for(var e=0;e<t.JSON_PROPERTIES.length;e++){var s=t.JSON_PROPERTIES[e];t[s]!==null&&t[s].buffer&&t[s].set?t[s].set(i[s]):t[s]=i[s]}},toJSON:function(t){for(var i={},e=0;e<t.JSON_PROPERTIES.length;e++){var s=t.JSON_PROPERTIES[e];i[s]=t[s]}return i}}});var j=x((qt,Q)=>{var z=N(),K=function(t){this.nes=t,this.mem=null,this.REG_ACC=null,this.REG_X=null,this.REG_Y=null,this.REG_SP=null,this.REG_PC=null,this.REG_PC_NEW=null,this.REG_STATUS=null,this.F_CARRY=null,this.F_DECIMAL=null,this.F_INTERRUPT=null,this.F_INTERRUPT_NEW=null,this.F_OVERFLOW=null,this.F_SIGN=null,this.F_ZERO=null,this.F_NOTUSED=null,this.F_NOTUSED_NEW=null,this.F_BRK=null,this.F_BRK_NEW=null,this.opdata=null,this.cyclesToHalt=null,this.crash=null,this.irqRequested=null,this.irqType=null,this.reset()};K.prototype={IRQ_NORMAL:0,IRQ_NMI:1,IRQ_RESET:2,reset:function(){this.mem=new Uint8Array(65536);for(var t=0;t<8192;t++)this.mem[t]=255;for(var i=0;i<4;i++){var e=i*2048;this.mem[e+8]=247,this.mem[e+9]=239,this.mem[e+10]=223,this.mem[e+15]=191}for(var s=8193;s<this.mem.length;s++)this.mem[s]=0;this.REG_ACC=0,this.REG_X=0,this.REG_Y=0,this.REG_SP=511,this.REG_PC=32768-1,this.REG_PC_NEW=32768-1,this.REG_STATUS=40,this.setStatus(40),this.F_CARRY=0,this.F_DECIMAL=0,this.F_INTERRUPT=1,this.F_INTERRUPT_NEW=1,this.F_OVERFLOW=0,this.F_SIGN=0,this.F_ZERO=1,this.F_NOTUSED=1,this.F_NOTUSED_NEW=1,this.F_BRK=1,this.F_BRK_NEW=1,this.opdata=new J().opdata,this.cyclesToHalt=0,this.crash=!1,this.irqRequested=!1,this.irqType=null},emulate:function(){var t,i;if(this.irqRequested){switch(t=this.F_CARRY|(this.F_ZERO===0?1:0)<<1|this.F_INTERRUPT<<2|this.F_DECIMAL<<3|this.F_BRK<<4|this.F_NOTUSED<<5|this.F_OVERFLOW<<6|this.F_SIGN<<7,this.REG_PC_NEW=this.REG_PC,this.F_INTERRUPT_NEW=this.F_INTERRUPT,this.irqType){case 0:{if(this.F_INTERRUPT!==0)break;this.doIrq(t);break}case 1:{this.doNonMaskableInterrupt(t);break}case 2:{this.doResetInterrupt();break}}this.REG_PC=this.REG_PC_NEW,this.F_INTERRUPT=this.F_INTERRUPT_NEW,this.F_BRK=this.F_BRK_NEW,this.irqRequested=!1}var e=this.opdata[this.nes.mmap.load(this.REG_PC+1)],s=e>>24,n=0,a=e>>8&255,r=this.REG_PC;this.REG_PC+=e>>16&255;var h=0;switch(a){case 0:{h=this.load(r+2);break}case 1:{h=this.load(r+2),h<128?h+=this.REG_PC:h+=this.REG_PC-256;break}case 2:break;case 3:{h=this.load16bit(r+2);break}case 4:{h=this.REG_ACC;break}case 5:{h=this.REG_PC;break}case 6:{h=this.load(r+2)+this.REG_X&255;break}case 7:{h=this.load(r+2)+this.REG_Y&255;break}case 8:{h=this.load16bit(r+2),(h&65280)!=(h+this.REG_X&65280)&&(n=1),h+=this.REG_X;break}case 9:{h=this.load16bit(r+2),(h&65280)!=(h+this.REG_Y&65280)&&(n=1),h+=this.REG_Y;break}case 10:{h=this.load(r+2),(h&65280)!=(h+this.REG_X&65280)&&(n=1),h+=this.REG_X,h&=255,h=this.load16bit(h);break}case 11:{h=this.load16bit(this.load(r+2)),(h&65280)!=(h+this.REG_Y&65280)&&(n=1),h+=this.REG_Y;break}case 12:{h=this.load16bit(r+2),h<8191?h=this.mem[h]+(this.mem[h&65280|(h&255)+1&255]<<8):h=this.nes.mmap.load(h)+(this.nes.mmap.load(h&65280|(h&255)+1&255)<<8);break}}switch(h&=65535,e&255){case 0:{t=this.REG_ACC+this.load(h)+this.F_CARRY,((this.REG_ACC^this.load(h))&128)==0&&((this.REG_ACC^t)&128)!=0?this.F_OVERFLOW=1:this.F_OVERFLOW=0,this.F_CARRY=t>255?1:
|
|
|
|
`,s}startProbing(){var i=new w(this);return this.connectProbe(i),i}stopProbing(){this.connectProbe(null)}connectProbe(i){this.probe=i||this.nullProbe}showHelp(i,e){window.open("https://8bitworkshop.com/docs/platforms/nes/","_help")}},Tt=class extends H{constructor(){super(...arguments);this.getToolForFilename=O;this.getOpcodeMetadata=Y}start(){}loadROM(i,e){if(!this.started)this.startModule(this.mainElement,{jsfile:"mame8bitws.js",driver:"nes",width:256,height:240,romfn:"/emulator/cart.nes",romdata:new Uint8Array(e),preInit:function(a){}});else{var s=e[4]*16384,n=e[5]*8192;this.loadROMFile(e),this.loadRegion(":nes_slot:cart:prg_rom",e.slice(16,16+s)),this.loadRegion(":nes_slot:cart:chr_rom",e.slice(16+s,16+s+n))}}getPresets(){return Et}getDefaultExtension(){return".c"}};b.nes=y;b["nes-asm"]=y;b["nes.mame"]=Tt;
|