1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-19 09:31:24 +00:00
8bitworkshop/gen/vicdual-AV7KC3DX.js

3 lines
3.1 KiB
JavaScript
Raw Normal View History

import{H as A,c as d,d as y,e as S,k as v,o as g}from"./chunk-5KW3VA4L.js";import"./chunk-5B4VPQ4V.js";import{I as p,U as t,V as u,X as h,_ as r}from"./chunk-ZDSSTLWD.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,M=o/8,P=o/3/w,j=P/328,U=M/P,V=500,Z=M/(2*V),T=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=_*T;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 b,this.handler=u(this.inputs,L,this.getKeyboardFunction()),this.psg=new S(new y),this.audioadapter=new v(this.psg.psg,T,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}},b=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 F=i*256,x=F,k=i>>3<<5,C=i&7,a=0;a<32;a++)for(var m=e[k+a],D=e[2048+(m<<3)+C],l=(m>>5)+(this.palbank<<3),E=this.palette[this.colorprom[l]>>1&7],O=this.palette[this.colorprom[l]>>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)}};p.vicdual=R;
//# sourceMappingURL=vicdual-AV7KC3DX.js.map