1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-06-01 05:41:31 +00:00
8bitworkshop/gen/chunk-42IVW2OL.js

27 lines
122 KiB
JavaScript
Raw Normal View History

import{D as ht,P as At,R as Ct,T as vt,U as St,V as nt,_ as gt,g as a0,j as dt,s as tt}from"./chunk-S4FPTY4A.js";var xn=[{mn:"BRK",am:"",nb:1,il:0,c1:7,c2:0,nw:3,br:1,mod:"SI"},{mn:"ORA",am:"(aa,x)",nb:2,il:0,c1:6,c2:0,nw:0,br:0,mod:"AZN"},{mn:"KIL",am:"",nb:1,il:2,c1:3,c2:0,nw:0,br:1,mod:""},{mn:"SLO",am:"(aa,x)",nb:2,il:1,c1:8,c2:0,nw:2,br:0,mod:"ACZN"},{mn:"NOP",am:"aa",nb:2,il:1,c1:3,c2:0,nw:0,br:0,mod:""},{mn:"ORA",am:"aa",nb:2,il:0,c1:3,c2:0,nw:0,br:0,mod:"AZN"},{mn:"ASL",am:"aa",nb:2,il:0,c1:5,c2:0,nw:2,br:0,mod:"CZN"},{mn:"SLO",am:"aa",nb:2,il:1,c1:5,c2:0,nw:2,br:0,mod:"ACZN"},{mn:"PHP",am:"",nb:1,il:0,c1:3,c2:0,nw:1,br:0,mod:"S"},{mn:"ORA",am:"#aa",nb:2,il:0,c1:2,c2:0,nw:0,br:0,mod:"AZN"},{mn:"ASL",am:"",nb:1,il:0,c1:2,c2:0,nw:0,br:0,mod:"ACZN"},{mn:"ANC",am:"#aa",nb:2,il:1,c1:2,c2:0,nw:0,br:0,mod:"ACZN"},{mn:"NOP",am:"AAAA",nb:3,il:1,c1:3,c2:0,nw:0,br:0,mod:""},{mn:"ORA",am:"AAAA",nb:3,il:0,c1:4,c2:0,nw:0,br:0,mod:"AZN"},{mn:"ASL",am:"AAAA",nb:3,il:0,c1:6,c2:0,nw:2,br:0,mod:"CZN"},{mn:"SLO",am:"AAAA",nb:3,il:1,c1:6,c2:0,nw:2,br:0,mod:"ACZN"},{mn:"BPL",am:"branch",nb:2,il:0,c1:2,c2:2,nw:0,br:1,mod:""},{mn:"ORA",am:"(aa),y",nb:2,il:0,c1:5,c2:1,nw:0,br:0,mod:"AZN"},{mn:"KIL",am:"",nb:1,il:2,c1:3,c2:0,nw:0,br:1,mod:""},{mn:"SLO",am:"(aa),y",nb:2,il:1,c1:8,c2:0,nw:2,br:0,mod:"ACZN"},{mn:"NOP",am:"aa,x",nb:2,il:1,c1:4,c2:0,nw:0,br:0,mod:""},{mn:"ORA",am:"aa,x",nb:2,il:0,c1:4,c2:0,nw:0,br:0,mod:"AZN"},{mn:"ASL",am:"aa,x",nb:2,il:0,c1:6,c2:0,nw:2,br:0,mod:"CZN"},{mn:"SLO",am:"aa,x",nb:2,il:1,c1:6,c2:0,nw:2,br:0,mod:"ACZN"},{mn:"CLC",am:"",nb:1,il:0,c1:2,c2:0,nw:0,br:0,mod:"C"},{mn:"ORA",am:"AAAA,y",nb:3,il:0,c1:4,c2:1,nw:0,br:0,mod:"AZN"},{mn:"NOP",am:"",nb:1,il:1,c1:2,c2:0,nw:0,br:0,mod:""},{mn:"SLO",am:"AAAA,y",nb:3,il:1,c1:7,c2:0,nw:2,br:0,mod:"ACZN"},{mn:"NOP",am:"AAAA,x",nb:3,il:1,c1:4,c2:0,nw:0,br:0,mod:""},{mn:"ORA",am:"AAAA,x",nb:3,il:0,c1:4,c2:1,nw:0,br:0,mod:"AZN"},{mn:"ASL",am:"AAAA,x",nb:3,il:0,c1:7,c2:0,nw:2,br:0,mod:"CZN"},{mn:"SLO",am:"AAAA,x",nb:3,il:1,c1:7,c2:0,nw:2,br:0,mod:"ACZN"},{mn:"JSR",am:"AAAA",nb:3,il:0,c1:6,c2:0,nw:2,br:1,mod:"S"},{mn:"AND",am:"(aa,x)",nb:2,il:0,c1:6,c2:0,nw:0,br:0,mod:"AZN"},{mn:"KIL",am:"",nb:1,il:2,c1:3,c2:0,nw:0,br:1,mod:""},{mn:"RLA",am:"(aa,x)",nb:2,il:1,c1:8,c2:0,nw:2,br:0,mod:"ACZN"},{mn:"BIT",am:"aa",nb:2,il:0,c1:3,c2:0,nw:0,br:0,mod:"ZVN"},{mn:"AND",am:"aa",nb:2,il:0,c1:3,c2:0,nw:0,br:0,mod:"AZN"},{mn:"ROL",am:"aa",nb:2,il:0,c1:5,c2:0,nw:2,br:0,mod:"CZN"},{mn:"RLA",am:"aa",nb:2,il:1,c1:5,c2:0,nw:2,br:0,mod:"ACZN"},{mn:"PLP",am:"",nb:1,il:0,c1:4,c2:0,nw:0,br:0,mod:"SCZIDVN"},{mn:"AND",am:"#aa",nb:2,il:0,c1:2,c2:0,nw:0,br:0,mod:"AZN"},{mn:"ROL",am:"",nb:1,il:0,c1:2,c2:0,nw:0,br:0,mod:"ACZN"},{mn:"ANC",am:"#aa",nb:2,il:1,c1:2,c2:0,nw:0,br:0,mod:"ACZN"},{mn:"BIT",am:"AAAA",nb:3,il:0,c1:4,c2:0,nw:0,br:0,mod:"ZVN"},{mn:"AND",am:"AAAA",nb:3,il:0,c1:4,c2:0,nw:0,br:0,mod:"AZN"},{mn:"ROL",am:"AAAA",nb:3,il:0,c1:6,c2:0,nw:2,br:0,mod:"CZN"},{mn:"RLA",am:"AAAA",nb:3,il:1,c1:6,c2:0,nw:2,br:0,mod:"ACZN"},{mn:"BMI",am:"branch",nb:2,il:0,c1:2,c2:2,nw:0,br:1,mod:""},{mn:"AND",am:"(aa),y",nb:2,il:0,c1:5,c2:1,nw:0,br:0,mod:"AZN"},{mn:"KIL",am:"",nb:1,il:2,c1:3,c2:0,nw:0,br:1,mod:""},{mn:"RLA",am:"(aa),y",nb:2,il:1,c1:8,c2:0,nw:2,br:0,mod:"ACZN"},{mn:"NOP",am:"aa,x",nb:2,il:1,c1:4,c2:0,nw:0,br:0,mod:""},{mn:"AND",am:"aa,x",nb:2,il:0,c1:4,c2:0,nw:0,br:0,mod:"AZN"},{mn:"ROL",am:"aa,x",nb:2,il:0,c1:6,c2:0,nw:2,br:0,mod:"CZN"},{mn:"RLA",am:"aa,x",nb:2,il:1,c1:6,c2:0,nw:2,br:0,mod:"ACZN"},{mn:"SEC",am:"",nb:1,il:0,c1:2,c2:0,nw:0,br:0,mod:"C"},{mn:"AND",am:"AAAA,y",nb:3,il:0,c1:4,c2:1,nw:0,br:0,mod:"AZN"},{mn:"NOP",am:"",nb:1,il:1,c1:2,c2:0,nw:0,br:0,mod:""},{mn:"RLA",am:"AAAA,y",nb:3,il:1,c1:7,c2:0,nw:2,br:0,mod:"ACZN"},{mn:"NOP",am:"AAAA,x",nb:3,il:1,c1:4,c2:0,nw:0,br:0,mod:""},{mn:"AND",am:"AAAA,x",nb:3,il:0,c1:4,c2:1,nw:0,br:0,mod:"AZN"},{mn:"ROL",am:"AAAA,x",nb:3,il:0,c1:7,c2:0,nw:2,br:0,mod:"CZN"},{mn:"RLA",am:"AAAA,x",nb:3,il:1,c1:7,c2:0,nw:2,br:0,mod:"ACZN"},{mn:"RTI",am:"",nb:1,il:0,c1:6,c2:0,nw:0,br:1,mod:"SCZIDVN"},{mn:"EOR",am:"(aa,x)",nb:2,il:0,c1:6,c2:0,nw:0,br:0,mod:"AZN"},{mn
A: `+o.toString(16)+" X: "+d.toString(16)+" Y: "+x.toString(16)+" SP: "+m.toString(16)+" N"+a+" V"+W+" D"+y+" I"+p+" Z"+N+" C"+k+" "},this.breakpoint=function(l){if(this.trace)var C="CPU Breakpoint! "+(l?"("+l+")":"")+`
`+this.toString()};var bt=[7,6,0,8,3,3,5,5,3,2,2,2,4,4,6,6,2,5,0,8,4,4,6,6,2,4,0,7,4,4,7,7,6,6,0,8,3,3,5,5,4,2,2,2,4,4,6,6,2,5,0,8,4,4,6,6,2,4,0,7,4,4,7,7,6,6,0,8,3,3,5,5,3,2,2,2,3,4,6,6,2,5,0,8,4,4,6,6,2,4,0,7,4,4,7,7,6,6,0,8,3,3,5,5,4,2,2,2,5,4,6,6,2,5,0,8,4,4,6,6,2,4,0,7,4,4,7,7,0,6,0,6,3,3,3,3,2,0,2,0,4,4,4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0,3,3,3,3,2,2,0,0,2,2,2,3,1,3,1,0,0,3,0,0,2,2,2,2,2,2,2,2,1,2,1,0,3,3,3,3,2,2,0,2,2,2,2,2,1,3,1,0,3,3,3,3,2,2,0,2,2,2,2,2,1,2,1,2,3,3,3,3,2,2,0,2,2,2,2,2,1,3,0,3,3,3,3,3,2,2,0,2,2,2,2,2,1,2,1,0,3,3,3,3,2,2,0,2,2,2,2,2,1,3,0,3,3,3,3,3],Ln=[1,2,0,0,0,2,2,0,1,2,1,0,0,3,3,0,2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0,3,2,0,0,2,2,2,0,1,2,1,0,3,3,3,0,2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0,1,2,0,0,0,2,2,0,1,2,1,0,3,3,3,0,2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0,1,2,0,0,0,2,2,0,1,2,1,0,3,3,3,0,2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0,0,2,0,0,2,2,2,0,1,0,1,0,3,3,3,0,2,2,0,0,2,2,2,0,1,3,1,0,0,3,0,0,2,2,2,0,2,2,2,0,1,2,1,0,3,3,3,0,2,2,0,0,2,2,2,0,1,3,1,0,3,3,3,0,2,2,0,0,2,2,2,0,1,2,1,0,3,3,3,0,2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0,2,2,0,0,2,2,2,0,1,2,1,0,3,3,3,0,2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0];this.getOpcodeMetadata=function(l,C){return{opcode:l,mnenomic:s[l],minCycles:bt[l],maxCycles:bt[l]+sn[l],insnlength:on[l]}},this.setNMI=function(){A=nn(),G=1,c=c-1&65535},this.setIRQ=function(){p||(A=tn(),G=1,c=c-1&65535)},this.getSP=function(){return m},this.getPC=function(){return c-1&65535},this.getT=function(){return G},this.isHalted=function(){return s[u0]=="uKIL"},this.isPCStable=function(){return G==0}},ue;(function(c){c[c.None=0]="None",c[c.NMI=1]="NMI",c[c.IRQ=2]="IRQ"})(ue||(ue={}));var Cn=class{constructor(){this.cpu=new st;this.interruptType=0}connectMemoryBus(e){this.cpu.connectBus(e)}advanceClock(){if(this.interruptType&&this.isStable()){switch(this.interruptType){case 1:this.cpu.setNMI();break;case 2:this.cpu.setIRQ();break}this.interruptType=0}this.cpu.clockPulse()}advanceInsn(){do this.advanceClock();while(!this.isStable())}reset(){this.cpu.reset(),this.interruptType=0}interrupt(e){this.interruptType!=1&&(this.interruptType=e)}NMI(){this.interrupt(1)}IRQ(){this.interrupt(2)}getSP(){return this.cpu.getSP()}getPC(){return this.cpu.getPC()}isHalted(){return this.cpu.isHalted()}saveState(){var e=this.cpu.saveState();return e.it=this.interruptType,e}loadState(e){this.cpu.loadState(e),this.interruptType=e.it}isStable(){return this.cpu.isPCStable()}getOpcodeMetadata(e){return this.cpu.getOpcodeMetadata(e)}};var vn=class{constructor(e,r){this.symbolmap=e,this.debuginfo=r,this.addr2symbol=dt(e),this.addr2symbol[0]||(this.addr2symbol[0]="$00"),this.addr2symbol[65536]="__END__"}};function ge(h){return h&&typeof h.getDebugCategories=="function"}var Rt=class{constructor(){this.id2bp={}}getDebugCondition(){return Object.keys(this.id2bp).length==0?null:()=>{var e=!1;for(var r in this.id2bp)this.id2bp[r].cond()&&(e=!0);return e}}},Bt=class{constructor(){this.recorder=null;this.internalFiles={}}setRecorder(e){this.recorder=e}updateRecorder(){this.recorder&&this.isRunning()&&this.recorder.frameRequested()&&this.recorder.recordFrame(this.saveState())}inspect(e){return Sn(
A `+a0(h.A)+" "+(h.R?"":"BUSY")+`
X `+a0(h.X)+`
Y `+a0(h.Y)+" SP "+a0(h.SP)+`
`}var ze={cycletime:[7,6,0,8,3,3,5,5,3,2,2,2,4,4,6,6,2,5,0,8,4,4,6,6,2,4,0,7,4,4,7,7,6,6,0,8,3,3,5,5,4,2,2,2,4,4,6,6,2,5,0,8,4,4,6,6,2,4,0,7,4,4,7,7,6,6,0,8,3,3,5,5,3,2,2,2,3,4,6,6,2,5,0,8,4,4,6,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,2,0,2,2,2,2,2,1,3,0,3,3,3,3,3,1,2,0,2,2,2,2,2,1,2,1,2,3,3,3,3,2,2,0,2,2,2,2,2,1,3,0,3,3,3,3,3,0,2,0,2,2,2,2,2,1,0,1,0,3,3,3,3,2,2,0,0,2,2,2,3,1,3,1,0,0,3,0,0,2,2,2,2,2,2,2,2,1,2,1,0,3,3,3,3,2,2,0,2,2,2,2,2,1,3,1,0,3,3,3,3,2,2,0,2,2,2,2,2,1,2,1,2,3,3,3,3,2,2,0,2,2,2,2,2,1,3,0,3,3,3,3,3,2,2,0,2,2,2,2,2,1,2,1,0,3,3,3,3,2,2,0,2,2,2,2,2,1,3,0,3,3,3,3,3],validinsns:[1,2,0,0,0,2,2,0,1,2,1,0,0,3,3,0,2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0,3,2,0,0,2,2,2,0,1,2,1,0,3,3,3,0,2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0,1,2,0,0,0,2,2,0,1,2,1,0,3,3,3,0,2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0,1,2,0,0,0,2,2,0,1,2,1,0,3,3,3,0,2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0,0,2,0,0,2,2,2,0,1,0,1,0,3,3,3,0,2,2,0,0,2,2,2,0,1,3,1,0,0,3,0,0,2,2,2,0,2,2,2,0,1,2,1,0,3,3,3,0,2,2,0,0,2,2,2,0,1,3,1,0,3,3,3,0,2,2,0,0,2,2,2,0,1,2,1,0,3,3,3,0,2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0,2,2,0,0,2,2,2,0,1,2,1,0,3,3,3,0,2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0]};function It(h,e){return{opcode:h,minCycles:ze.cycletime[h],maxCycles:ze.cycletime[h]+ze.extracycles[h],insnlength:ze.insnlengths[h]}}function Lt(h){function e(r){return tt(r,["S","Z",,"H",,"V","N","C"],!0)}return"PC "+a0(h.PC,4)+" "+e(h.AF)+" "+(h.iff1?"I":"-")+(h.iff2?"I":"-")+`
SP `+a0(h.SP,4)+" IR "+a0(h.IR,4)+`
IX `+a0(h.IX,4)+" IY "+a0(h.IY,4)+`
AF `+a0(h.AF,4)+" BC "+a0(h.BC,4)+`
DE `+a0(h.DE,4)+" HL "+a0(h.HL,4)+`
`}var Ot=class extends We{constructor(){super(...arguments);this.waitCycles=0;this.getToolForFilename=Et}newCPU(e,r){return this._cpu=new at,this._cpu.connectMemoryBus(e),this._cpu.connectIOBus(r),this._cpu}getPC(){return this._cpu.getPC()}getSP(){return this._cpu.getSP()}isStable(){return!0}runCPU(e,r){if(this._cpu=e,this.waitCycles=0,this.wasBreakpointHit())return 0;var c=this.getDebugCallback(),m=0;for(this.waitCycles+=r;this.waitCycles>0;){if(c&&c()){c=null;break}var o=e.advanceInsn();m+=o,this.waitCycles-=o}return m}getDefaultExtension(){return".c"}getDebugCategories(){return["CPU","Stack"]}getDebugInfo(e,r){switch(e){case"CPU":return Lt(r.c);case"Stack":{var c=r.c.SP-1&65535,m=c&65280,o=m+255;return c==0&&(c=65536),console.log(c,m,o),ye(this,[],m,o,c,205)}}}disassemble(e,r){return ct(e,r(e),r(e+1),r(e+2),r(e+3))}};function Et(h){return h.endsWith(".c")||h.endsWith(".h")?"sdcc":h.endsWith(".s")?"sdasz80":h.endsWith(".ns")?"naken":h.endsWith(".scc")?"sccz80":h.endsWith(".z")?"zmac":h.endsWith(".wiz")?"wiz":"zmac"}function ot(h){function e(r){return tt(r,["E","F","H","I","N","Z","V","C"],!0)}return"PC "+a0(h.PC,4)+" "+e(h.CC)+`
SP `+a0(h.SP,4)+`
DP `+a0(h.DP,2)+`
A `+a0(h.A,2)+`
B `+a0(h.B,2)+`
X `+a0(h.X,4)+`
Y `+a0(h.Y,4)+`
U `+a0(h.U,4)+`
`}function Zt(h){return h.endsWith(".c")||h.endsWith(".h")?"cmoc":h.endsWith(".xasm")?"xasm6809":h.endsWith(".lwasm")?"lwasm":"cmoc"}var pn=class extends Ot{constructor(){super(...arguments);this.getToolForFilename=Zt}newCPU(e){var r=Object.create(Ye());return r.init(e.write,e.read,0),r}cpuStateToLongString(e){return ot(e)}disassemble(e,r){return Object.create(Ye()).disasm(r(e),r(e+1),r(e+2),r(e+3),r(e+4),e)}getDefaultExtension(){return".asm"}getDebugCategories(){return["CPU","Stack"]}getDebugInfo(e,r){switch(e){case"CPU":return ot(r.c);default:return super.getDebugInfo(e,r)}}};function ye(h,e,r,c,m,o,d){var x="",a=0;function W(k){return k<e.length?e[k]:h.readAddress(k)}for(;m<c;){m++;var y=W(m)+W(m+1)*256;d&&(y=(y&255)<<8|(y&65280)>>8);var p=o==32?-2:-3,N=W(y+p);N==o?(x+=`
$`+a0(m)+": ",x+=a0(y,4)+" "+_n(h,y,!0),m++,a=0):(a==0&&(x+=`
$`+a0(m)+": "),x+=a0(W(m))+" ",++a==8&&(a=0))}return x+`
`}function _n(h,e,r){for(var c=e,m=h.debugSymbols&&h.debugSymbols.addr2symbol;m&&e>=0;){var o=m[e];if(o){var o=m[e];return r?o+" + $"+a0(c-e):o}if(!r)break;e--}return""}function Pn(h){return typeof h.connectVideo=="function"}function kn(h){return typeof h.connectAudio=="function"}function wn(h){return typeof h.setKeyInput=="function"}function Mt(h){return typeof h.setPaddleInput=="function"}function xt(h){return typeof h.getRasterY=="function"}function Dn(h){return typeof h.connectProbe=="function"}function Rn(h){return typeof h.loadBIOS=="function"}function Bn(h){return typeof h.connectSerialIO=="function"}var Ke=class extends We{constructor(e){super();this.mainElement=e}reset(){this.machine.reset(),this.serialVisualizer!=null&&this.serialVisualizer.reset()}loadState(e){this.machine.loadState(e)}saveState(){return this.machine.saveState()}getSP(){return this.machine.cpu.getSP()}getPC(){return this.machine.cpu.getPC()}isStable(){return this.machine.cpu.isStable()}getCPUState(){return this.machine.cpu.saveState()}loadControlsState(e){this.machine.loadControlsState(e)}saveControlsState(){return this.machine.saveControlsState()}async start(){this.machine=this.newMachine();let e=this.machine;e instanceof Ve&&await e.loadWASM();var r;if(Pn(e)){var c=e.getVideoParams();this.video=new At(this.mainElement,c.width,c.height,{overscan:!!c.overscan,rotate:c.rotate|0,aspect:c.aspect}),this.video.create(),e.connectVideo(this.video.getFrameData()),wn(e)&&(this.video.setKeyboardEvents(e.setKeyInput.bind(e)),this.poller=new gt(e.setKeyInput.bind(e))),r=c.videoFrequency}if(this.timer=new St(r||60,this.nextFrame.bind(this)),kn(e)){var m=e.getAudioParams();this.audio=new it(m.sampleRate),this.audio.start(),e.connectAudio(this.audio)}Mt(e)&&this.video.setupMouseEvents(),Dn(e)&&(this.probeRecorder=new ft(e),this.startProbing=()=>(e.connectProbe(this.probeRecorder),this.probeRecorder),this.stopProbing=()=>{e.connectProbe(null)}),Rn(e)&&(this.loadBIOS=(o,d)=>{e.loadBIOS(d,o)}),Bn(e)&&(this.serialIOInterface==null?this.serialVisualizer=new Tt(this.mainElement,e):e.connectSerialIO(this.serialIOInterface))}loadROM(e,r){this.machine.loadROM(r,e),this.reset()}pollControls(){this.poller&&this.poller.poll(),Mt(this.machine)&&(this.machine.setPaddleInput(0,this.video.paddle_x),this.machine.setPaddleInput(1,this.video.paddle_y)),this.machine.pollControls&&this.machine.pollControls()}advance(e){let r=this.getDebugCallback();var c=this.machine.advanceFrame(r);return!e&&this.video&&(this.video.updateFrame(),this.updateVideoDebugger()),!e&&this.serialVisualizer&&this.serialVisualizer.refresh(),c}updateVideoDebugger(){var e;if(!this.isRunning()&&xt(this.machine)&&this.machine.getRasterCanvasPosition){let{x:r,y:c}=this.machine.getRasterCanvasPosition();if(r>=0||c>=0){let m=(e=this.video)==null?void 0:e.getContext();m&&Ct(m,r,c,1)}}}advanceFrameClock(e,r){if(r>0)return this.machine instanceof Ve?this.machine.advanceFrameClock(e,r):this.machine.advanceFrame(()=>--r<=0)}isRunning(){return this.timer&&this.timer.isRunning()}resume(){this.timer.start(),this.audio&&this.audio.start()}pause(){this.timer.stop(),this.audio&&this.audio.stop()}runToVsync(){this.restartDebugging();var e=!1;this.runEval(()=>{if(this.getRasterScanline()>0)e=!0;else return e})}getRasterScanline(){return xt(this.machine)&&this.machine.getRasterY?this.machine.getRasterY():-1}getRasterLineClock(){return xt(this.machine)&&this.machine.getRasterX?this.machine.getRasterX():-1}readAddress(e){return this.machine.read(e)}getDebugCategories(){if(ge(this.machine))return this.machine.getDebugCategories()}getDebugInfo(e,r){return ge(this.machine)&&this.machine.getDebugInfo(e,r)}},Nn=class extends Ke{constructor(){super(...arguments);this.getOpcodeMetadata=It}getToolForFilename(e){return Nt(e)}disassemble(e,r){return rt(e,r(e),r(e+1),r(e+2))}getDebugCategories(){return ge(this.machine)?this.machine.getDebugCategories():["CPU","ZPRAM","Stack"]}getDebugInfo(e,r){switch(e){case"CPU":return yt(r.c);case"ZPRAM":return nt(r.b||r.ram,0,256);case"Stack":return ye(this,r.b||r.ram,256,511,256+r.c.SP,32);default:r
`),c.op==="read"?r+="<< ":c.op==="write"&&(r+=">> "),e=c.op),c.value==10?(r+="\u21B5",e=""):r+=ht(c.value);this.textarea.value=r,this.lastOutCount=this.device.serialOut.length,this.textarea.style.display="block"}}};export{rt as a,ct as b,at as c,pt as d,mn as e,ln as f,Mn as g,bn as h,Tn as i,dn as j,hn as k,L0 as l,ft as m,He as n,_t as o,Pt as p,An as q,Ve as r,Ye as s,Cn as t,vn as u,ge as v,Bt as w,Sn as x,Nt as y,gn as z,yt as A,It as B,Lt as C,Ot as D,Et as E,pn as F,ye as G,Ke as H,Nn as I,yn as J,In as K};
//# sourceMappingURL=chunk-42IVW2OL.js.map