2023-10-31 16:30:11 +00:00
|
|
|
import{J as A,c as d,d as y,e as S,k as v,q as g}from"./chunk-TV4YGKI4.js";import{$ as r,J as p,V as t,W as u,Y as h}from"./chunk-Z5CU44VP.js";import"./chunk-5XVCUSSZ.js";var L=h([[t.A,2,-32],[t.B,2,-64],[t.LEFT,1,-16],[t.RIGHT,1,-32],[t.UP,1,-64],[t.DOWN,1,-128],[t.START,2,-16],[t.P2_START,3,-32],[t.SELECT,3,8]]),o=15468e3,w=262,K=224;var I=240,b=o/8,M=o/3/w,j=M/328,U=b/M,V=500,Z=b/(2*V),P=2,_=60*w,c=class extends g{constructor(){super();this.cpuFrequency=o/8;this.canvasWidth=256;this.numTotalScanlines=262;this.numVisibleScanlines=224;this.defaultROMSize=16448;this.sampleRate=_*P;this.cpuCyclesPerLine=U|0;this.rotate=-90;this.cpu=new d;this.ram=new Uint8Array(4096);this.read=r([[0,32767,16383,e=>this.rom?this.rom[e]:null],[32768,65535,4095,e=>this.ram[e]]]);this.write=r([[32768,65535,4095,(e,s)=>{this.ram[e]=s}]]);this.connectCPUMemoryBus(this),this.connectCPUIOBus(this.newIOBus()),this.inputs.set([255,255,255,255^8]),this.display=new T,this.handler=u(this.inputs,L,this.getKeyboardFunction()),this.psg=new S(new y),this.audioadapter=new v(this.psg.psg,P,this.sampleRate)}getKeyboardFunction(){return e=>{e.index==3&&e.mask==8&&(this.cpu.reset(),console.log("coin inserted"),console.log(this.inputs))}}newIOBus(){return{read:e=>this.inputs[e&3],write:(e,s)=>{e&1&&this.psg.selectRegister(s&15),e&2&&this.psg.setData(s),e&8,e&64&&(this.display.palbank=s&3)}}}reset(){super.reset(),this.psg.reset()}startScanline(){this.inputs[2]&=~8,this.inputs[2]|=(this.frameCycles/Z&1)<<3,this.scanline==K&&(this.inputs[1]|=8),this.scanline==I&&(this.inputs[1]&=~8),this.audio&&this.audioadapter.generate(this.audio)}drawScanline(){this.display.drawScanline(this.ram,this.pixels,this.scanline)}loadROM(e){super.loadROM(e),e.length>=16416&&(e[16384]||e[16415])&&(this.display.colorprom=e.slice(16384,16416))}loadState(e){super.loadState(e),this.display.palbank=e.pb}saveState(){var e=super.saveState();return e.pb=this.display.palbank,e}},T=class{constructor(){this.palbank=0;this.palette=[4278190080,4278190335,4278255360,4278255615,4294901760,4294902015,4294967040,4294967295];this.colorprom=[224,96,32,96,192,96,64,192,32,64,96,128,160,192,224,14,224,224,224,224,96,96,96,96,224,224,224,224,224,224,224,224]}drawScanline(e,s,i){if(!(i>=224))for(var k=i*256,x=k,F=i>>3<<5,C=i&7,a=0;a<32;a++)for(var l=e[F+a],D=e[2048+(l<<3)+C],m=(l>>5)+(this.palbank<<3),E=this.palette[this.colorprom[m]>>1&7],O=this.palette[this.colorprom[m]>>5&7],n=0;n<8;n++){var B=128>>n;s[x]=D&B?O:E,x++}}};var q=[{id:"minimal.c",name:"Minimal Example"},{id:"hello.c",name:"Hello World"},{id:"gfxtest.c",name:"Graphics Test"},{id:"soundtest.c",name:"Sound Test"},{id:"snake1.c",name:"Siege Game (Prototype)"},{id:"snake2.c",name:"Siege Game (Full)"},{id:"music.c",name:"Music Player"}],R=class extends A{constructor(){super(...arguments);this.getMemoryMap=function(){return{main:[{name:"Cell RAM",start:57344,size:32*32,type:"ram"},{name:"Tile RAM",start:59392,size:256*8,type:"ram"}]}}}newMachine(){return new c}getPresets(){return q}getDefaultExtension(){return".c"}readAddress(e){return this.machine.read(e)}showHelp(){return"https://8bitworkshop.com/docs/platforms/arcade/index.html#vic-dual"}};p.vicdual=R;
|