1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-05-28 08:41:30 +00:00

Deploying to gh-pages from @ sehugg/8bitworkshop@d4b8473b86 🚀

This commit is contained in:
sehugg 2023-07-12 21:24:18 +00:00
parent d865012dd4
commit 861684856f
19 changed files with 163 additions and 63 deletions

View File

@ -0,0 +1,7 @@
import{I as j,h as z,k as K,p as Y,t as $}from"./chunk-HB3LWF25.js";import{$ as R,J as _,U as T,V as c,W,Y as N,_ as F,da as H,g as A}from"./chunk-ATS7PSQG.js";import"./chunk-5XVCUSSZ.js";var g=0,B=2,w=8,Z=N([[c.A,w+0,128],[c.B,w+1,128],[c.SELECT,B,-2],[c.START,B,-1],[c.UP,g,-16],[c.DOWN,g,-32],[c.LEFT,g,-64],[c.RIGHT,g,-128],[c.P2_A,w+2,128],[c.P2_B,w+3,128],[c.P2_UP,g,-1],[c.P2_DOWN,g,-2],[c.P2_LEFT,g,-4],[c.P2_RIGHT,g,-8]]);var k=263,V=258-16,C=451,tt=28,et=16,rt=24,G=2,X=k*60*G,O=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+=T(t.regs,0,32),e}},U=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.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}}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}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?rt:et,this.offset<0&&this.readDLLEntry(t);let o=this.dlstart&65280,s=this.dlstart&255;do{let u=t.read(o+(s+0&511)),a=t.read(o+(s+1&511));if(a==0||o>=16384)break;let p=t.read(o+(s+2&511)),b=t.read(o+(s+3&511)),d=!1,m=a&128;if((a&31)==0){var i=b>>5,f=32-(b&31),r=t.read(o+(s+4&511));d=(a&32)!=0,s+=5,this.cycles+=10}else{var r=b,i=a>>5,f=32-(a&31);s+=4,this.cycles+=8}this.indirect=d;let D=u+((p+(d?0:this.offset)&255)<<8);r*=2;let y=this.regs[28],M=(y&3)+(m?4:0),S=(y&4)!=0,L=d&&(y&16)!=0;L&&(f*=2);for(var x=0;x<f;x++){let h=this.readDMA(L?D+(x>>1):D+x);if(d){let v=(this.regs[20]+this.offset<<8)+h;L&&x&1&&(v++,this.cycles-=3),h=this.readDMA(v)}switch(M){case 0:for(let n=0;n<4;n++){let l=h>>6&3;(l||S)&&(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||S)&&(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||S)&&(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||S)&&(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||S)&&(e[r]=this.regs[(i<<2)+l]),h<<=1,r=r+1&511}break;case 7:let v=h;for(let n=0;n<4;n++){n==2&&(v<<=2);let l=(h&128)>>6,Q=i&4|v>>2&3;(l||S)&&(e[r]=this.regs[(Q<<2)+l]),h<<=1,r=r+1&511}break}}}while(this.cycles<C);this.offset-=1}return this.cycles}doInterrupt(){return this.dli&&this.offset<0?(this.dli=!1,!0):!1}static stateToLongString(t){let e="";return e+=T(t.regs,0,32),e+=`
DLL: $`+A((t.regs[12]<<8)+t.regs[16],4)+" @ $"+A(t.dll,4),e+=`
DL: $`+A(t.dlstart,4),e+=`
Offset: `+t.offset,e+=`
DLI? `+t.dli,e}},E=class extends Y{constructor(){super();this.cpuFrequency=1789772;this.canvasWidth=320;this.numTotalScanlines=k;this.numVisibleScanlines=V;this.defaultROMSize=49152;this.cpuCyclesPerLine=113.5;this.sampleRate=X;this.ram=new Uint8Array(4096);this.regs6532=new Uint8Array(4);this.piatimer=0;this.timerinterval=1;this.tia=new O;this.maria=new U;this.lastFrameCycles=0;this.xtracyc=0;this.cpu=new $,this.read=R([[8,13,15,t=>(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=R([[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=W(this.inputs,Z),this.pokey1=new z,this.audioadapter=new K(this.pokey1,G,X)}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<<e,this.timerinterval=e}getPIATimerValue(){let t=this.piatimer;return t>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,o=0;this.probe.logNewFrame();for(var s=0;s<k;s++){this.scanline=s;var u=s<V;for(this.maria.setVBLANK(!u),this.maria.WSYNC=0;r<tt&&!this.maria.WSYNC;){if(t&&t()){t=null,s=999;break}r+=this.advanceCPU()<<2,o++}if(u){let p=this.maria.doDMA(this.dmaBus);if(this.tickClocks(p>>2),r+=p,e){let m=(this.maria.regs[28]&128)!=0?15:255;for(var a=0;a<320;a++)e[i++]=q[this.maria.pixels[a]&m]}}for((u||s==k-1)&&this.maria.doInterrupt()&&(this.probe.logInterrupt(0),this.cpu.NMI());r<C;){if(this.maria.WSYNC){this.probe.logWait(0),this.tickClocks(C-r>>2),r=C;break}if(t&&t()){t=null,s=999;break}r+=this.advanceCPU()<<2,o++}this.audio&&this.audioadapter.generate(this.audio),r-=C,x+=r,this.probe.logNewScanline()}return this.lastFrameCycles=x,o}getRasterX(){return this.lastFrameCycles%C}getRasterY(){return this.scanline}loadROM(t){t.length==49280&&(t=t.slice(128)),this.rom=F(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 O.stateToLongString(e.tia);case"MARIA":return U.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,o=(f&32)!=0,s=(this.readConst(e+1)<<8)+this.readConst(e+2);e=e+3&65535;let u=(this.readConst(e)&128)!=0,a="DL $"+A(s,4)+" "+i+"-"+(i+r);x&&(a+=" H16"),o&&(a+=" H8"),u&&(a+=" DLI"),t[a]={$$:this._readDebugDisplayList(s)},i+=r+1}return t}_readDebugDisplayList(t){return()=>this.readDebugDisplayList(t)}readDebugDisplayList(t){let e=[],i=t&65280,f=t&255;do{let u=this.readConst(i+(f+0&511)),a=this.readConst(i+(f+1&511));if(a==0)break;let p=this.readConst(i+(f+2&511)),b=this.readConst(i+(f+3&511)),d=!1,m="";if((a&31)==0){var r=b>>5,x=32-(b&31),o=this.readConst(i+(f+4&511)),s=a&128;d=(a&32)!=0,f+=5,m+="X="+o+" W="+x+" P="+r+" "+(s?"WRITE":"")}else{var o=b,r=a>>5,x=32-(a&31),s=0;f+=4,m+="X="+o+" W="+x+" P="+r}let D=u+((p+(d?0:this.maria.offset)&255)<<8),y=(this.maria.regs[28]&3)+(s?4:0),M=d&&(this.maria.regs[28]&16)!=0;y&&(m+=" READMODE="+y),M&&(m+=" DBL"),d&&(m+=" CHR=$"+A(this.maria.regs[20]+this.maria.offset&255)+"xx"),m=" $"+A(D,4)+" "+m,e.push(m)}while(f<512);return e}},q=new Uint32Array(256);for(P=0;P<256;P++)q[P]=H(P);var P;var it=[{id:"sprites.dasm",name:"Sprites (ASM)"},{id:"wsync.c",name:"WSYNC"},{id:"sprites.c",name:"Double Buffering"},{id:"scroll.c",name:"Scrolling"}],J=class extends j{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 E}getPresets(){return it}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}};_.atari7800=J;
//# sourceMappingURL=atari7800-6OOZFJYK.js.map

File diff suppressed because one or more lines are too long

View File

@ -1,7 +0,0 @@
import{I as z,h as W,k as N,p as F,t as H}from"./chunk-HB3LWF25.js";import{$ as M,J as B,U as I,V as f,W as O,Y as U,_ as E,da as _,g}from"./chunk-ATS7PSQG.js";import"./chunk-5XVCUSSZ.js";var d=0,L=2,P=8,X=U([[f.A,P+0,128],[f.B,P+1,128],[f.SELECT,L,-2],[f.START,L,-1],[f.UP,d,-16],[f.DOWN,d,-32],[f.LEFT,d,-64],[f.RIGHT,d,-128],[f.P2_A,P+2,128],[f.P2_B,P+3,128],[f.P2_UP,d,-1],[f.P2_DOWN,d,-2],[f.P2_LEFT,d,-4],[f.P2_RIGHT,d,-8]]);var D=263,K=258-16,b=451,j=28,q=16,J=24,Y=2,$=D*60*Y,T=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+=I(t.regs,0,32),e}},k=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.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}}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}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){if(this.bus=t,this.cycles=0,this.pixels.fill(this.regs[0]),this.isDMAEnabled()){this.cycles+=this.offset==0?J:q,this.offset<0&&this.readDLLEntry(t);let i=this.dlstart&65280,h=this.dlstart&255;do{let n=t.read(i+(h+0&511)),c=t.read(i+(h+1&511));if(c==0||i>=16384)break;let A=t.read(i+(h+2&511)),m=t.read(i+(h+3&511)),x=!1;if((c&31)==0){var e=m>>5,a=32-(m&31),r=t.read(i+(h+4&511)),s=c&128;x=(c&32)!=0,h+=5,this.cycles+=10}else{var r=m,e=c>>5,a=32-(c&31),s=0;h+=4,this.cycles+=8}this.indirect=x;let v=n+((A+(x?0:this.offset)&255)<<8);r*=2;let C=(this.regs[28]&3)+(s?4:0),y=x&&(this.regs[28]&16)!=0;y&&(a*=2);for(var o=0;o<a;o++){let p=this.readDMA(y?v+(o>>1):v+o);if(x){let u=(this.regs[20]+this.offset<<8)+p;y&&o&1&&(u++,this.cycles-=3),p=this.readDMA(u)}switch(C){case 0:for(let u=0;u<4;u++){var l=p>>6&3;l>0&&(this.pixels[r]=this.pixels[r+1]=this.regs[(e<<2)+l]),p<<=2,r=r+2&511}break;case 2:case 3:for(let u=0;u<8;u++){var l=p&128?1:0;l>0&&(this.pixels[r]=this.regs[(e<<2)+l]),p<<=1,r=r+1&511}break}}}while(this.cycles<b);this.offset-=1}return this.cycles}doInterrupt(){return this.dli&&this.offset<0?(this.dli=!1,!0):!1}static stateToLongString(t){let e="";return e+=I(t.regs,0,32),e+=`
DLL: $`+g((t.regs[12]<<8)+t.regs[16],4)+" @ $"+g(t.dll,4),e+=`
DL: $`+g(t.dlstart,4),e+=`
Offset: `+t.offset,e+=`
DLI? `+t.dli,e}},R=class extends F{constructor(){super();this.cpuFrequency=1789772;this.canvasWidth=320;this.numTotalScanlines=D;this.numVisibleScanlines=K;this.defaultROMSize=49152;this.cpuCyclesPerLine=113.5;this.sampleRate=$;this.ram=new Uint8Array(4096);this.regs6532=new Uint8Array(4);this.piatimer=0;this.timerinterval=1;this.tia=new T;this.maria=new k;this.lastFrameCycles=0;this.xtracyc=0;this.cpu=new H,this.read=M([[8,13,15,t=>(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=M([[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=O(this.inputs,X),this.pokey1=new W,this.audioadapter=new N(this.pokey1,Y,$)}readConst(t){let e=this.probe;this.probe=null;let a=this.read(t);return this.probe=e,a}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<<e,this.timerinterval=e}getPIATimerValue(){let t=this.piatimer;return t>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,a=0,r,s=0,o=0,l=0;this.probe.logNewFrame();for(var i=0;i<D;i++){this.scanline=i;var h=i<K;for(this.maria.setVBLANK(!h),this.maria.WSYNC=0;s<j&&!this.maria.WSYNC;){if(t&&t()){t=null,i=999;break}s+=this.advanceCPU()<<2,l++}if(h){let c=this.maria.doDMA(this.dmaBus);if(this.tickClocks(c>>2),s+=c,e)for(var n=0;n<320;n++)e[a++]=V[this.maria.pixels[n]]}for((h||i==D-1)&&this.maria.doInterrupt()&&(this.probe.logInterrupt(0),this.cpu.NMI());s<b;){if(this.maria.WSYNC){this.probe.logWait(0),this.tickClocks(b-s>>2),s=b;break}if(t&&t()){t=null,i=999;break}s+=this.advanceCPU()<<2,l++}this.audio&&this.audioadapter.generate(this.audio),s-=b,o+=s,this.probe.logNewScanline()}return this.lastFrameCycles=o,l}getRasterX(){return this.lastFrameCycles%b}getRasterY(){return this.scanline}loadROM(t){t.length==49280&&(t=t.slice(128)),this.rom=E(t,this.defaultROMSize,!0)}reset(){super.reset(),this.tia.reset(),this.maria.reset(),this.inputs.fill(0),this.inputs[d]=255,this.inputs[L]=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 T.stateToLongString(e.tia);case"MARIA":return k.stateToLongString(e.maria)+`
Scanline: `+this.scanline}}getDebugDisplayLists(){let t={},e=this.maria.getDLLStart(),a=0;for(;a<240;){let r=this.readConst(e),s=r&15,o=(r&64)!=0,l=(r&32)!=0,i=(this.readConst(e+1)<<8)+this.readConst(e+2);e=e+3&65535;let h=(this.readConst(e)&128)!=0,n="DL $"+g(i,4)+" "+a+"-"+(a+s);o&&(n+=" H16"),l&&(n+=" H8"),h&&(n+=" DLI"),t[n]={$$:this._readDebugDisplayList(i)},a+=s+1}return t}_readDebugDisplayList(t){return()=>this.readDebugDisplayList(t)}readDebugDisplayList(t){let e=[],a=t&65280,r=t&255;do{let h=this.readConst(a+(r+0&511)),n=this.readConst(a+(r+1&511));if(n==0)break;let c=this.readConst(a+(r+2&511)),A=this.readConst(a+(r+3&511)),m=!1,x="";if((n&31)==0){var s=A>>5,o=32-(A&31),l=this.readConst(a+(r+4&511)),i=n&128;m=(n&32)!=0,r+=5,x+="X="+l+" W="+o+" P="+s+" "+(i?"WRITE":"")}else{var l=A,s=n>>5,o=32-(n&31),i=0;r+=4,x+="X="+l+" W="+o+" P="+s}let v=h+((c+(m?0:this.maria.offset)&255)<<8),C=(this.maria.regs[28]&3)+(i?4:0),y=m&&(this.maria.regs[28]&16)!=0;C&&(x+=" READMODE="+C),y&&(x+=" DBL"),m&&(x+=" CHR=$"+g(this.maria.regs[20]+this.maria.offset&255)+"xx"),x=" $"+g(v,4)+" "+x,e.push(x)}while(r<512);return e}},V=new Uint32Array(256);for(S=0;S<256;S++)V[S]=_(S);var S;var Q=[{id:"sprites.dasm",name:"Sprites (ASM)"},{id:"wsync.c",name:"WSYNC"},{id:"sprites.c",name:"Double Buffering"},{id:"scroll.c",name:"Scrolling"}],G=class extends z{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 R}getPresets(){return Q}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}};B.atari7800=G;
//# sourceMappingURL=atari7800-N22FZCY6.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,2 +1,2 @@
import{a as d}from"./chunk-3XE5YOCV.js";import{o as c}from"./chunk-NDAI7GI2.js";import"./chunk-SXEVG2WS.js";import"./chunk-5SHCNQ2O.js";import"./chunk-3ZY5KX5H.js";import{I as m,o as u,t as h}from"./chunk-HB3LWF25.js";import{$ as i,B as o,J as l,m as n}from"./chunk-ATS7PSQG.js";import"./chunk-5XVCUSSZ.js";var s=31,a=class extends u{constructor(){super();this.cpuFrequency=1e6;this.defaultROMSize=32768;this.cpu=new h;this.ram=new Uint8Array(16384);this.read=i([[0,16383,16383,e=>this.ram[e]],[16384,16384,65535,e=>this.serial.byteAvailable()?128:0],[16385,16385,65535,e=>this.serial.recvByte()],[16386,16386,65535,e=>this.serial.clearToSend()?128:0],[32768,65535,32767,e=>this.rom&&this.rom[e]]]);this.write=i([[0,16383,16383,(e,t)=>{this.ram[e]=t}],[16387,16387,65535,(e,t)=>this.serial.sendByte(t)],[16399,16399,65535,(e,t)=>{this.inputs[s]=1}]]);this.connectCPUMemoryBus(this)}connectSerialIO(e){this.serial=e}readConst(e){return this.read(e)}advanceFrame(e){for(var t=0;t<this.cpuFrequency/60&&!(e&&e());)t+=this.advanceCPU();return t}advanceCPU(){if(this.isHalted())return 1;var e=super.advanceCPU();return this.serial&&this.serial.advance(e),e}reset(){this.inputs[s]=0,super.reset(),this.serial&&this.serial.reset()}isHalted(){return this.inputs[s]!=0}};var S=[{id:"hello.dasm",name:"Hello World (ASM)"}],f=class{constructor(e){e.style.overflowY="auto";var t=$('<div id="gameport"/>').appendTo(e);$('<p class="transcript-header">Serial Output</p>').appendTo(t);var y=$('<div id="windowport" class="transcript"/>').appendTo(t);this.div=y[0]}start(){this.tty=new d(this.div,!1)}reset(){this.tty.clear()}saveState(){return this.tty.saveState()}loadState(e){this.tty.loadState(e)}};function p(r){return r==10?"":r<32?String.fromCharCode(r+9216):String.fromCharCode(r)}var v=class{constructor(){this.bufferedRead=!0;this.cyclesPerByte=1e6/(57600/8);this.maxOutputBytes=4096}clearToSend(){return this.outputBytes.length<this.maxOutputBytes}sendByte(e){this.clearToSend()&&(this.outputBytes.push(e),this.viewer.tty.addtext(p(e),2|32),e==10&&this.viewer.tty.newline(),this.clearToSend()||(this.viewer.tty.newline(),this.viewer.tty.addtext("\u26A0\uFE0F OUTPUT BUFFER FULL \u26A0\uFE0F",4)))}byteAvailable(){return this.readIndex()>this.inputIndex}recvByte(){var e=this.readIndex();this.inputIndex=e;var t=(this.inputBytes&&this.inputBytes[e])|0;return this.viewer.tty.addtext(p(t),2|16),t==10&&this.viewer.tty.newline(),t}readIndex(){return this.bufferedRead?this.inputIndex+1:Math.floor(this.clk/this.cyclesPerByte)}reset(){this.inputIndex=-1,this.clk=0,this.outputBytes=[],this.bufin=""}advance(e){this.clk+=e}saveState(){return{clk:this.clk,idx:this.inputIndex,out:this.outputBytes.slice()}}loadState(e){this.clk=e.clk,this.inputIndex=e.idx,this.outputBytes=e.out.slice()}},x=class extends m{constructor(e){super(e);this.getMemoryMap=function(){return{main:[{name:"RAM",start:0,size:16384,type:"ram"},{name:"ROM",start:32768,size:32768,type:"rom"}]}};this.serview=new f(e)}async start(){super.start(),this.serial=new v,this.serial.viewer=this.serview,this.serview.start(),this.machine.connectSerialIO(this.serial)}reset(){this.serial.inputBytes=o(this.internalFiles["serialin.dat"]),super.reset(),this.serview.reset()}isBlocked(){return this.machine.isHalted()}advance(e){return this.isBlocked()?(this.internalFiles["serialout.dat"]=n(this.serial.outputBytes),c(),0):super.advance(e)}saveState(){var e=super.saveState();return e.serial=this.serial.saveState(),e.serview=this.serview.saveState(),e}loadState(e){super.loadState(e),this.serial.loadState(e.serial),this.serview.loadState(e.serview)}newMachine(){return new a}getPresets(){return S}getDefaultExtension(){return".dasm"}readAddress(e){return this.machine.readConst(e)}};l["devel-6502"]=x;export{v as SerialTestHarness};
//# sourceMappingURL=devel-N6DPMGWQ.js.map
import{a as d}from"./chunk-3XE5YOCV.js";import{o as c}from"./chunk-CHQ274AD.js";import"./chunk-SXEVG2WS.js";import"./chunk-5SHCNQ2O.js";import"./chunk-W3NHMPMI.js";import{I as m,o as u,t as h}from"./chunk-HB3LWF25.js";import{$ as i,B as o,J as l,m as n}from"./chunk-ATS7PSQG.js";import"./chunk-5XVCUSSZ.js";var s=31,a=class extends u{constructor(){super();this.cpuFrequency=1e6;this.defaultROMSize=32768;this.cpu=new h;this.ram=new Uint8Array(16384);this.read=i([[0,16383,16383,e=>this.ram[e]],[16384,16384,65535,e=>this.serial.byteAvailable()?128:0],[16385,16385,65535,e=>this.serial.recvByte()],[16386,16386,65535,e=>this.serial.clearToSend()?128:0],[32768,65535,32767,e=>this.rom&&this.rom[e]]]);this.write=i([[0,16383,16383,(e,t)=>{this.ram[e]=t}],[16387,16387,65535,(e,t)=>this.serial.sendByte(t)],[16399,16399,65535,(e,t)=>{this.inputs[s]=1}]]);this.connectCPUMemoryBus(this)}connectSerialIO(e){this.serial=e}readConst(e){return this.read(e)}advanceFrame(e){for(var t=0;t<this.cpuFrequency/60&&!(e&&e());)t+=this.advanceCPU();return t}advanceCPU(){if(this.isHalted())return 1;var e=super.advanceCPU();return this.serial&&this.serial.advance(e),e}reset(){this.inputs[s]=0,super.reset(),this.serial&&this.serial.reset()}isHalted(){return this.inputs[s]!=0}};var S=[{id:"hello.dasm",name:"Hello World (ASM)"}],f=class{constructor(e){e.style.overflowY="auto";var t=$('<div id="gameport"/>').appendTo(e);$('<p class="transcript-header">Serial Output</p>').appendTo(t);var y=$('<div id="windowport" class="transcript"/>').appendTo(t);this.div=y[0]}start(){this.tty=new d(this.div,!1)}reset(){this.tty.clear()}saveState(){return this.tty.saveState()}loadState(e){this.tty.loadState(e)}};function p(r){return r==10?"":r<32?String.fromCharCode(r+9216):String.fromCharCode(r)}var v=class{constructor(){this.bufferedRead=!0;this.cyclesPerByte=1e6/(57600/8);this.maxOutputBytes=4096}clearToSend(){return this.outputBytes.length<this.maxOutputBytes}sendByte(e){this.clearToSend()&&(this.outputBytes.push(e),this.viewer.tty.addtext(p(e),2|32),e==10&&this.viewer.tty.newline(),this.clearToSend()||(this.viewer.tty.newline(),this.viewer.tty.addtext("\u26A0\uFE0F OUTPUT BUFFER FULL \u26A0\uFE0F",4)))}byteAvailable(){return this.readIndex()>this.inputIndex}recvByte(){var e=this.readIndex();this.inputIndex=e;var t=(this.inputBytes&&this.inputBytes[e])|0;return this.viewer.tty.addtext(p(t),2|16),t==10&&this.viewer.tty.newline(),t}readIndex(){return this.bufferedRead?this.inputIndex+1:Math.floor(this.clk/this.cyclesPerByte)}reset(){this.inputIndex=-1,this.clk=0,this.outputBytes=[],this.bufin=""}advance(e){this.clk+=e}saveState(){return{clk:this.clk,idx:this.inputIndex,out:this.outputBytes.slice()}}loadState(e){this.clk=e.clk,this.inputIndex=e.idx,this.outputBytes=e.out.slice()}},x=class extends m{constructor(e){super(e);this.getMemoryMap=function(){return{main:[{name:"RAM",start:0,size:16384,type:"ram"},{name:"ROM",start:32768,size:32768,type:"rom"}]}};this.serview=new f(e)}async start(){super.start(),this.serial=new v,this.serial.viewer=this.serview,this.serview.start(),this.machine.connectSerialIO(this.serial)}reset(){this.serial.inputBytes=o(this.internalFiles["serialin.dat"]),super.reset(),this.serview.reset()}isBlocked(){return this.machine.isHalted()}advance(e){return this.isBlocked()?(this.internalFiles["serialout.dat"]=n(this.serial.outputBytes),c(),0):super.advance(e)}saveState(){var e=super.saveState();return e.serial=this.serial.saveState(),e.serview=this.serview.saveState(),e}loadState(e){super.loadState(e),this.serial.loadState(e.serial),this.serview.loadState(e.serview)}newMachine(){return new a}getPresets(){return S}getDefaultExtension(){return".dasm"}readAddress(e){return this.machine.readConst(e)}};l["devel-6502"]=x;export{v as SerialTestHarness};
//# sourceMappingURL=devel-DOTGQZOW.js.map

View File

@ -1,2 +1,2 @@
import{b as w,c as x}from"./chunk-3ZY5KX5H.js";import{D as v,J as c,k as m,l as u,x as g,z as p}from"./chunk-ATS7PSQG.js";import{e as I}from"./chunk-5XVCUSSZ.js";var h=I(x()),i,a,l,y=function(e){if(!e||e.length==0)return{};for(var r={},t=0;t<e.length;++t){var o=e[t].split("=",2);o.length==1?r[o[0]]="":r[o[0]]=decodeURIComponent(o[1].replace(/\+/g," "))}return r}(window.location.search.substr(1).split("&"));function P(){typeof window.onerror=="object"&&(window.onerror=function(e,r,t,o,n){var s=e+" "+r+" "+t+":"+o+", "+n;$.get("/error?msg="+encodeURIComponent(s),"text")})}function M(){var e=!1;document.addEventListener("visibilitychange",function(r){document.visibilityState=="hidden"&&a.isRunning()?(a.pause(),e=!0):document.visibilityState=="visible"&&e&&(a.resume(),e=!1)}),$(window).on("focus",function(){e&&(a.resume(),e=!1)}),$(window).on("blur",function(){a.isRunning()&&(a.pause(),e=!0)})}async function k(e,r){if(!r){alert("No ROM found.");return}console.log(r.length+" bytes"),await a.loadROM(e,r),a.resume()}function R(){return $("#emulator").find("canvas")}function E(e,r,t){v("gif.js/dist/gif.js").then(()=>{var o=R()[0];if(!o){alert("Could not find canvas element to record video!");return}var n=0;o.style&&o.style.transform&&(o.style.transform.indexOf("rotate(-90deg)")>=0?n=-1:o.style.transform.indexOf("rotate(90deg)")>=0&&(n=1));var s=new GIF({workerScript:"gif.js/dist/gif.worker.js",workers:4,quality:10,rotate:n});s.on("finished",function(C){console.log("finished encoding GIF"),t(C)}),e=e||100+(Math.random()*256&3),r=r||100+(Math.random()*256&15);var f=0;console.log("Recording video",o);var d=()=>{f++>r?(console.log("Rendering video"),s.render()):(s.addFrame(o,{delay:e,copy:!0}),setTimeout(d,e))};d()})}async function S(e){if(!c[i])throw Error("Invalid platform '"+i+"'.");a=new c[i]($("#emuscreen")[0]),await a.start(),e.rec&&R().on("focus",()=>{a.resume()});var r=e.n||"Game",t,o=e.url,n=e.r;if(o)return console.log(o),g(o,f=>{k(r,f)},"arraybuffer"),!0;if(n){var s=u(atob(n));t=new m().decode(s)}return M(),k(r,t),!0}async function b(e){if(e.data&&(e=e.data),i=e.p,!i)throw new Error("No platform variable!");try{var r=await w(p(i));console.log("starting platform",i),await S(e)}catch(t){console.log(t),alert('Platform "'+i+'" not supported.')}}function F(){P(),y.p&&b(y)}window.addEventListener("message",O,!1);function O(e){if(e.data){var r=e.data.cmd;if(r=="start"&&!a)b(e);else if(r=="reset")a.reset(),l.reset();else if(r=="getReplay"){var t={frameCount:l.frameCount,checkpoints:l.checkpoints,framerecs:l.framerecs,checkpointInterval:l.checkpointInterval,maxCheckpoints:l.maxCheckpoints};e.source.postMessage({ack:r,replay:t},e.origin)}else if(r=="watchState"){var o=new Function("platform","state",e.data.fn);l.callbackNewCheckpoint=n=>{e.source.postMessage({ack:r,state:o(a,n)},e.origin)}}else r=="recordVideo"?E(e.data.intervalMsec,e.data.maxFrames,function(n){e.data.filename&&(0,h.saveAs)(n,e.data.filename),e.source.postMessage({ack:r,gif:n},e.origin)}):console.log("Unknown data.cmd: "+r)}}self===top&&(document.body.style.backgroundColor="#555");F();export{a as platform,i as platform_id,F as startEmbed,l as stateRecorder};
import{b as w,c as x}from"./chunk-W3NHMPMI.js";import{D as v,J as c,k as m,l as u,x as g,z as p}from"./chunk-ATS7PSQG.js";import{e as I}from"./chunk-5XVCUSSZ.js";var h=I(x()),i,a,l,y=function(e){if(!e||e.length==0)return{};for(var r={},t=0;t<e.length;++t){var o=e[t].split("=",2);o.length==1?r[o[0]]="":r[o[0]]=decodeURIComponent(o[1].replace(/\+/g," "))}return r}(window.location.search.substr(1).split("&"));function P(){typeof window.onerror=="object"&&(window.onerror=function(e,r,t,o,n){var s=e+" "+r+" "+t+":"+o+", "+n;$.get("/error?msg="+encodeURIComponent(s),"text")})}function M(){var e=!1;document.addEventListener("visibilitychange",function(r){document.visibilityState=="hidden"&&a.isRunning()?(a.pause(),e=!0):document.visibilityState=="visible"&&e&&(a.resume(),e=!1)}),$(window).on("focus",function(){e&&(a.resume(),e=!1)}),$(window).on("blur",function(){a.isRunning()&&(a.pause(),e=!0)})}async function k(e,r){if(!r){alert("No ROM found.");return}console.log(r.length+" bytes"),await a.loadROM(e,r),a.resume()}function R(){return $("#emulator").find("canvas")}function E(e,r,t){v("gif.js/dist/gif.js").then(()=>{var o=R()[0];if(!o){alert("Could not find canvas element to record video!");return}var n=0;o.style&&o.style.transform&&(o.style.transform.indexOf("rotate(-90deg)")>=0?n=-1:o.style.transform.indexOf("rotate(90deg)")>=0&&(n=1));var s=new GIF({workerScript:"gif.js/dist/gif.worker.js",workers:4,quality:10,rotate:n});s.on("finished",function(C){console.log("finished encoding GIF"),t(C)}),e=e||100+(Math.random()*256&3),r=r||100+(Math.random()*256&15);var f=0;console.log("Recording video",o);var d=()=>{f++>r?(console.log("Rendering video"),s.render()):(s.addFrame(o,{delay:e,copy:!0}),setTimeout(d,e))};d()})}async function S(e){if(!c[i])throw Error("Invalid platform '"+i+"'.");a=new c[i]($("#emuscreen")[0]),await a.start(),e.rec&&R().on("focus",()=>{a.resume()});var r=e.n||"Game",t,o=e.url,n=e.r;if(o)return console.log(o),g(o,f=>{k(r,f)},"arraybuffer"),!0;if(n){var s=u(atob(n));t=new m().decode(s)}return M(),k(r,t),!0}async function b(e){if(e.data&&(e=e.data),i=e.p,!i)throw new Error("No platform variable!");try{var r=await w(p(i));console.log("starting platform",i),await S(e)}catch(t){console.log(t),alert('Platform "'+i+'" not supported.')}}function F(){P(),y.p&&b(y)}window.addEventListener("message",O,!1);function O(e){if(e.data){var r=e.data.cmd;if(r=="start"&&!a)b(e);else if(r=="reset")a.reset(),l.reset();else if(r=="getReplay"){var t={frameCount:l.frameCount,checkpoints:l.checkpoints,framerecs:l.framerecs,checkpointInterval:l.checkpointInterval,maxCheckpoints:l.maxCheckpoints};e.source.postMessage({ack:r,replay:t},e.origin)}else if(r=="watchState"){var o=new Function("platform","state",e.data.fn);l.callbackNewCheckpoint=n=>{e.source.postMessage({ack:r,state:o(a,n)},e.origin)}}else r=="recordVideo"?E(e.data.intervalMsec,e.data.maxFrames,function(n){e.data.filename&&(0,h.saveAs)(n,e.data.filename),e.source.postMessage({ack:r,gif:n},e.origin)}):console.log("Unknown data.cmd: "+r)}}self===top&&(document.body.style.backgroundColor="#555");F();export{a as platform,i as platform_id,F as startEmbed,l as stateRecorder};
//# sourceMappingURL=embedui.js.map

View File

@ -176,7 +176,8 @@ class MARIA {
doDMA(bus) {
this.bus = bus;
this.cycles = 0;
this.pixels.fill(this.regs[0x0]);
const pix = this.pixels;
pix.fill(this.regs[0x0]); // background color
if (this.isDMAEnabled()) {
// last line in zone gets additional 8 cycles
this.cycles += this.offset == 0 ? colorClocksShutdownLast : colorClocksShutdownOther;
@ -200,12 +201,12 @@ class MARIA {
let b2 = bus.read(dlhi + ((dlofs + 2) & 0x1ff));
let b3 = bus.read(dlhi + ((dlofs + 3) & 0x1ff));
let indirect = false;
const writemode = b1 & 0x80;
// extended header?
if ((b1 & 31) == 0) {
var pal = b3 >> 5;
var width = 32 - (b3 & 31);
var xpos = bus.read(dlhi + ((dlofs + 4) & 0x1ff));
var writemode = b1 & 0x80;
indirect = (b1 & 0x20) != 0;
dlofs += 5;
this.cycles += 10;
@ -215,17 +216,19 @@ class MARIA {
var xpos = b3;
var pal = b1 >> 5;
var width = 32 - (b1 & 31);
var writemode = 0;
dlofs += 4;
this.cycles += 8;
}
this.indirect = indirect;
let gfxadr = b0 + (((b2 + (indirect ? 0 : this.offset)) & 0xff) << 8);
const gfxadr = b0 + (((b2 + (indirect ? 0 : this.offset)) & 0xff) << 8);
xpos *= 2;
// copy graphics data (direct)
let readmode = (this.regs[0x1c] & 0x3) + (writemode ? 4 : 0);
const ctrlreg = this.regs[0x1c];
// gfx mode (readmode + writemode * 4)
const grmode = (ctrlreg & 0x3) + (writemode ? 4 : 0);
// kangaroo mode
const kangaroo = (ctrlreg & 0x4) != 0;
// double bytes?
let dbl = indirect && (this.regs[0x1c] & 0x10) != 0;
const dbl = indirect && (ctrlreg & 0x10) != 0;
if (dbl) {
width *= 2;
}
@ -241,23 +244,67 @@ class MARIA {
data = this.readDMA(indadr);
}
// TODO: more modes (https://github.com/gstanton/ProSystem1_3/blob/master/Core/Maria.cpp)
switch (readmode) {
case 0: // 160 A/B
switch (grmode) {
case 0: // 160A
for (let j = 0; j < 4; j++) {
var col = (data >> 6) & 3;
if (col > 0) {
this.pixels[xpos] = this.pixels[xpos + 1] = this.regs[(pal << 2) + col];
let col = (data >> 6) & 3;
if (col || kangaroo) {
pix[xpos] = pix[xpos + 1] = this.regs[(pal << 2) + col];
}
data <<= 2;
xpos = (xpos + 2) & 0x1ff;
}
break;
case 2: // 320 B/D (TODO?)
case 3: // 320 A/C
case 3: // 320A
for (let j = 0; j < 8; j++) {
var col = (data & 128) ? 1 : 0;
if (col > 0) {
this.pixels[xpos] = this.regs[(pal << 2) + col];
let col = (data & 0x80) >> 6;
if (col || kangaroo) {
pix[xpos] = this.regs[(pal << 2) + col];
}
data <<= 1;
xpos = (xpos + 1) & 0x1ff;
}
break;
case 4: // 160B
for (let j = 0; j < 2; j++) {
let col = ((data >> 6) & 0b0011) + (data & 0b1100);
if ((col & 3) || kangaroo) {
pix[xpos] = pix[xpos + 1] = pix[xpos + 2] = pix[xpos + 3] = this.regs[((pal & 4) << 2) + col];
}
data <<= 2;
xpos = (xpos + 2) & 0x1ff;
}
break;
case 6: // 320B
for (let j = 0; j < 4; j++) {
let col = ((data & 0x80) >> 6) | ((data & 0x08) >> 3);
if (col || kangaroo) {
pix[xpos] = this.regs[(pal << 2) + col];
}
data <<= 1;
xpos = (xpos + 1) & 0x1ff;
}
break;
case 2: // 320D
for (let j = 0; j < 8; j++) {
let col = ((data & 0x80) >> 6);
col += (j & 1) ? (pal & 1) : ((pal >> 1) & 1);
if (col || kangaroo) {
pix[xpos] = this.regs[(pal << 2) + col];
}
data <<= 1;
xpos = (xpos + 1) & 0x1ff;
}
break;
case 7: // 320C
let data0 = data;
for (let j = 0; j < 4; j++) {
if (j == 2)
data0 <<= 2;
let col = (data & 0x80) >> 6;
let ppal = (pal & 4) | ((data0 >> 2) & 3);
if (col || kangaroo) {
pix[xpos] = this.regs[(ppal << 2) + col];
}
data <<= 1;
xpos = (xpos + 1) & 0x1ff;
@ -461,8 +508,11 @@ class Atari7800 extends devices_1.BasicMachine {
mc += dmaClocks;
// copy line to frame buffer
if (idata) {
const ctrlreg = this.maria.regs[0x1c];
const colorkill = (ctrlreg & 0x80) != 0;
const mask = colorkill ? 0x0f : 0xff;
for (var i = 0; i < 320; i++) {
idata[iofs++] = COLORS_RGBA[this.maria.pixels[i]];
idata[iofs++] = COLORS_RGBA[this.maria.pixels[i] & mask];
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,2 +1,2 @@
import{b as a,c as b,d as c,e as d,f as e,g as f,h as g,i as h,j as i,k as j,l as k,m as l,n as m,o as n,p as o,q as p,r as q,s as r,t as s,u as t,v as u,w as v,x as w}from"./chunk-NDAI7GI2.js";import"./chunk-SXEVG2WS.js";import"./chunk-5SHCNQ2O.js";import"./chunk-3ZY5KX5H.js";import"./chunk-HB3LWF25.js";import"./chunk-ATS7PSQG.js";import"./chunk-5XVCUSSZ.js";export{l as clearBreakpoint,h as compparams,f as current_project,u as emulationHalted,p as getPlatformAndRepo,t as getSaveState,s as getTestOutput,n as haltEmulation,w as highlightSearch,i as lastDebugState,e as platform,b as platform_id,g as projectWindows,a as qs,v as reloadWorkspaceFile,d as repo_id,k as runToPC,m as setFrameRateUI,r as setTestInput,j as setupBreakpoint,o as setupSplits,q as startUI,c as store_id};
import{b as a,c as b,d as c,e as d,f as e,g as f,h as g,i as h,j as i,k as j,l as k,m as l,n as m,o as n,p as o,q as p,r as q,s as r,t as s,u as t,v as u,w as v,x as w}from"./chunk-CHQ274AD.js";import"./chunk-SXEVG2WS.js";import"./chunk-5SHCNQ2O.js";import"./chunk-W3NHMPMI.js";import"./chunk-HB3LWF25.js";import"./chunk-ATS7PSQG.js";import"./chunk-5XVCUSSZ.js";export{l as clearBreakpoint,h as compparams,f as current_project,u as emulationHalted,p as getPlatformAndRepo,t as getSaveState,s as getTestOutput,n as haltEmulation,w as highlightSearch,i as lastDebugState,e as platform,b as platform_id,g as projectWindows,a as qs,v as reloadWorkspaceFile,d as repo_id,k as runToPC,m as setFrameRateUI,r as setTestInput,j as setupBreakpoint,o as setupSplits,q as startUI,c as store_id};
//# sourceMappingURL=ui.js.map

View File

@ -7,6 +7,7 @@ import { hex, rgb2bgr } from "../common/util";
// https://atarihq.com/danb/a7800.shtml
// https://atarihq.com/danb/files/maria_r1.txt
// https://atarihq.com/danb/files/7800vid.txt
// https://sites.google.com/site/atari7800wiki/
interface Atari7800StateBase {
@ -202,7 +203,8 @@ class MARIA {
doDMA(bus : Bus) {
this.bus = bus;
this.cycles = 0;
this.pixels.fill(this.regs[0x0]);
const pix = this.pixels;
pix.fill(this.regs[0x0]); // background color
if (this.isDMAEnabled()) {
// last line in zone gets additional 8 cycles
this.cycles += this.offset == 0 ? colorClocksShutdownLast : colorClocksShutdownOther;
@ -223,12 +225,12 @@ class MARIA {
let b2 = bus.read(dlhi + ((dlofs+2) & 0x1ff));
let b3 = bus.read(dlhi + ((dlofs+3) & 0x1ff));
let indirect = false;
const writemode = b1 & 0x80;
// extended header?
if ((b1 & 31) == 0) {
var pal = b3 >> 5;
var width = 32 - (b3 & 31);
var xpos = bus.read(dlhi + ((dlofs+4) & 0x1ff));
var writemode = b1 & 0x80;
indirect = (b1 & 0x20) != 0;
dlofs += 5;
this.cycles += 10;
@ -237,17 +239,19 @@ class MARIA {
var xpos = b3;
var pal = b1 >> 5;
var width = 32 - (b1 & 31);
var writemode = 0;
dlofs += 4;
this.cycles += 8;
}
this.indirect = indirect;
let gfxadr = b0 + (((b2 + (indirect?0:this.offset)) & 0xff) << 8);
const gfxadr = b0 + (((b2 + (indirect?0:this.offset)) & 0xff) << 8);
xpos *= 2;
// copy graphics data (direct)
let readmode = (this.regs[0x1c] & 0x3) + (writemode?4:0);
const ctrlreg = this.regs[0x1c];
// gfx mode (readmode + writemode * 4)
const grmode = (ctrlreg & 0x3) + (writemode ? 4 : 0);
// kangaroo mode
const kangaroo = (ctrlreg & 0x4) != 0;
// double bytes?
let dbl = indirect && (this.regs[0x1c] & 0x10) != 0;
const dbl = indirect && (ctrlreg & 0x10) != 0;
if (dbl) { width *= 2; }
//if (this.offset == 0) console.log(hex(dla,4), hex(gfxadr,4), xpos, width, pal, readmode);
for (var i=0; i<width; i++) {
@ -261,23 +265,66 @@ class MARIA {
data = this.readDMA(indadr);
}
// TODO: more modes (https://github.com/gstanton/ProSystem1_3/blob/master/Core/Maria.cpp)
switch (readmode) {
case 0: // 160 A/B
switch (grmode) {
case 0: // 160A
for (let j=0; j<4; j++) {
var col = (data >> 6) & 3;
if (col > 0) {
this.pixels[xpos] = this.pixels[xpos+1] = this.regs[(pal<<2) + col];
let col = (data >> 6) & 3;
if (col || kangaroo) {
pix[xpos] = pix[xpos+1] = this.regs[(pal<<2) + col];
}
data <<= 2;
xpos = (xpos + 2) & 0x1ff;
}
break;
case 2: // 320 B/D (TODO?)
case 3: // 320 A/C
case 3: // 320A
for (let j=0; j<8; j++) {
var col = (data & 128) ? 1 : 0;
if (col > 0) {
this.pixels[xpos] = this.regs[(pal<<2) + col];
let col = (data & 0x80) >> 6;
if (col || kangaroo) {
pix[xpos] = this.regs[(pal<<2) + col];
}
data <<= 1;
xpos = (xpos + 1) & 0x1ff;
}
break;
case 4: // 160B
for (let j=0; j<2; j++) {
let col = ((data >> 6) & 0b0011) + (data & 0b1100);
if ((col & 3) || kangaroo) {
pix[xpos] = pix[xpos+1] = pix[xpos+2] = pix[xpos+3] = this.regs[((pal&4)<<2) + col];
}
data <<= 2;
xpos = (xpos + 2) & 0x1ff;
}
break;
case 6: // 320B
for (let j=0; j<4; j++) {
let col = ((data & 0x80) >> 6) | ((data & 0x08) >> 3);
if (col || kangaroo) {
pix[xpos] = this.regs[(pal<<2) + col];
}
data <<= 1;
xpos = (xpos + 1) & 0x1ff;
}
break;
case 2: // 320D
for (let j=0; j<8; j++) {
let col = ((data & 0x80) >> 6);
col += (j & 1) ? (pal & 1) : ((pal >> 1) & 1);
if (col || kangaroo) {
pix[xpos] = this.regs[(pal<<2) + col];
}
data <<= 1;
xpos = (xpos + 1) & 0x1ff;
}
break;
case 7: // 320C
let data0 = data;
for (let j=0; j<4; j++) {
if (j == 2) data0 <<= 2;
let col = (data & 0x80) >> 6;
let ppal = (pal & 4) | ((data0 >> 2) & 3);
if (col || kangaroo) {
pix[xpos] = this.regs[(ppal<<2) + col];
}
data <<= 1;
xpos = (xpos + 1) & 0x1ff;
@ -491,8 +538,11 @@ export class Atari7800 extends BasicMachine implements RasterFrameBased {
mc += dmaClocks;
// copy line to frame buffer
if (idata) {
const ctrlreg = this.maria.regs[0x1c];
const colorkill = (ctrlreg & 0x80) != 0;
const mask = colorkill ? 0x0f : 0xff;
for (var i=0; i<320; i++) {
idata[iofs++] = COLORS_RGBA[this.maria.pixels[i]];
idata[iofs++] = COLORS_RGBA[this.maria.pixels[i] & mask];
}
}
}