Files
8bitworkshop/gen/c64-RILK5FDC.js
T

15 lines
9.2 KiB
JavaScript

import{a as M}from"./chunk-WIKZL6VD.js";import{A as _,J as y,s as b,x as S}from"./chunk-2XSLQJUY.js";import{K as n,V as f,a as x,g as a,v as d}from"./chunk-TYDI7JZQ.js";import"./chunk-VSC4MAII.js";var m=class extends b{constructor(){super(...arguments);this.numTotalScanlines=312;this.cpuCyclesPerLine=63;this.joymask0=0;this.joymask1=0;this.lightpen_x=0;this.lightpen_y=0}loadBIOS(e){super.loadBIOS(e)}reset(){super.reset();for(var e=0;e<128;e++)this.exports.machine_key_up(this.sys,e);if(this.romptr&&this.romlen){if(this.exports.machine_load_rom(this.sys,this.romptr,this.romlen),this.prgstart=this.romarr[0]+(this.romarr[1]<<8),this.prgstart==2049)if(this.romarr[6]==158){for(var i=0,t=0;t<5;t++){var e=this.romarr[7+t];if(e==155||e==0)break;i=i*10+(e&15)}this.prgstart=i,console.log("SYS",i,a(i))}else this.prgstart=this.romarr[2]+(this.romarr[3]<<8)+2,console.log("RUN",this.prgstart,a(this.prgstart));if(this.prgstart<32768){this.exports.machine_exec(this.sys,25e4);for(var s="\rSYS "+this.prgstart,t=0;t<s.length;t++){var r=s.charCodeAt(t);this.exports.machine_exec(this.sys,3e4),this.exports.machine_key_down(this.sys,r),this.exports.machine_exec(this.sys,3e4),this.exports.machine_key_up(this.sys,r),this.exports.machine_exec(this.sys,1)}this.exports.machine_key_down(this.sys,13),this.exports.machine_exec(this.sys,1);for(var t=0;t<1e5&&this.getPC()!=this.prgstart;t++)this.exports.machine_tick(this.sys);this.exports.machine_key_up(this.sys,13),this.exports.machine_exec(this.sys,1)}else{this.exports.machine_exec(this.sys,100);for(var o=this.romarr[4]+this.romarr[5]*256,t=0;t<15e4&&this.getPC()!=o;t++)this.exports.machine_tick(this.sys)}}}advanceFrame(e){var i=this.getRasterY(),t=Math.floor((this.numTotalScanlines-i)*19656/this.numTotalScanlines),s=this.probe!=null;return s&&this.exports.machine_reset_probe_buffer(),t=super.advanceFrameClock(e,t),s&&this.copyProbeData(),t}getCPUState(){this.exports.machine_save_cpu_state(this.sys,this.cpustateptr);var e=this.cpustatearr,i=e[2]+(e[3]<<8);return{PC:i,SP:e[9],A:e[6],X:e[7],Y:e[8],C:e[10]&1,Z:e[10]&2,I:e[10]&4,D:e[10]&8,V:e[10]&64,N:e[10]&128,o:this.readConst(i),R:e[19]!=55}}saveState(){this.exports.machine_save_state(this.sys,this.stateptr);let e=this.getDebugStateOffset(1),i=this.getDebugStateOffset(2),t=this.getDebugStateOffset(3),s=this.getDebugStateOffset(4),r=this.getDebugStateOffset(5),o=this.getDebugStateOffset(9);return{c:this.getCPUState(),state:this.statearr.slice(0),ram:this.statearr.slice(r,r+65536),cia1:this.statearr.slice(e,e+64),cia2:this.statearr.slice(i,i+64),vic:this.statearr.slice(t+1,t+1+64),sid:this.statearr.slice(s,s+32),pla:this.statearr.slice(o,o+16),joymask0:this.joymask0,joymask1:this.joymask1}}loadState(e){this.statearr.set(e.state),this.exports.machine_load_state(this.sys,this.stateptr),this.joymask0=e.joymask0|0,this.joymask1=e.joymask1|0,this.exports.c64_joystick(this.sys,this.joymask0,this.joymask1)}getVideoParams(){return{width:392,height:272,overscan:!0,videoFrequency:50,aspect:392/272*.9365}}setKeyInput(e,i,t){if(!(e==16||e==17||e==18||e==224)){var s=0,r=0;switch(e){case 32:s=r=16;break;case 37:e=8,s=r=4;break;case 38:e=11,s=r=1;break;case 39:e=9,s=r=8;break;case 40:e=10,s=r=2;break;case 113:e=241;break;case 115:e=243;break;case 119:e=245;break;case 121:e=247;break;case 188:e=t&2?60:46;break;case 190:e=t&2?62:44;break;case 191:e=t&2?63:47;break;case 222:e=t&2?34:39;break;case 219:e=t&2?123:91;break;case 221:e=t&2?125:93;break;case 48:t&2&&(e=41);break;case 49:t&2&&(e=33);break;case 50:t&2&&(e=64);break;case 51:t&2&&(e=35);break;case 52:t&2&&(e=36);break;case 53:t&2&&(e=37);break;case 54:t&2&&(e=94);break;case 55:t&2&&(e=38);break;case 56:t&2&&(e=42);break;case 57:t&2&&(e=40);break;case 59:t&2&&(e=58);break;case 61:t&2&&(e=43);break;case 173:e=t&2?95:45;break}t&1?(this.exports.machine_key_down(this.sys,e),this.joymask0|=s,this.joymask1|=r):t&64&&(this.exports.machine_key_up(this.sys,e),this.joymask0&=~s,this.joymask1&=~r),this.exports.c64_joystick(this.sys,this.joymask0,this.joymask1)}}getRasterX(){return this.statearr[244]}getRasterY(){return this.exports.machine_get_raster_line(this.sys)}getRasterCanvasPosition(){return{x:this.getRasterX()*392/63,y:this.getRasterY()-14}}getDebugStateOffset(e){var i=this.exports.machine_get_debug_pointer(this.sys,e);return i-this.sys}getDebugCategories(){return["CPU","ZPRAM","Stack","PLA","CIA","VIC","SID"]}getDebugInfo(e,i){switch(e){case"PLA":{let t="",s=i.pla[0],r=i.pla[3];return t+=`$0000 - $9FFF RAM
`,t+=`$A000 - $BFFF ${(r&3)==3?"BASIC ROM":"RAM"}
`,t+=`$C000 - $CFFF RAM
`,t+=`$D000 - $DFFF ${s?"I/O":(r&3)!=0?"CHAR ROM":"RAM"}
`,t+=`$E000 - $FFFF ${(r&2)==2?"KERNAL ROM":"RAM"}
`,t}case"CIA":{let t="";for(let s=0;s<2;s++){let r=s?i.cia2:i.cia1;t+=`CIA ${s+1}
`,t+=` A: Data ${a(r[0])} DDR ${a(r[1])} Input ${a(r[2])}`,t+=` Timer ${a(r[10]+r[11]*256,4)}
`,t+=` B: Data ${a(r[4])} DDR ${a(r[5])} Input ${a(r[6])}`,t+=` Timer ${a(r[20]+r[21]*256,4)}
`}return t}case"VIC":{let t=i.vic,s="",r=(i.cia2[0]&3^3)*16384,o=r+(i.vic[24]&14)*1024,l=r+(i.vic[24]>>4)*1024,p=i.vic[17]&32,C=(i.cia2[0]&1)==1&&(i.vic[24]&12)==4,A=i.state[244],I=this.getRasterY();return s+="Mode:",i.vic[17]&32?s+=" BITMAP":s+=" CHAR",i.vic[22]&16&&(s+=" MULTICOLOR"),i.vic[17]&64&&(s+=" EXTENDED"),s+=`
`,s+=`Raster: (${x(A,3)}, ${x(I,3)}) `,s+=`Scroll: (${i.vic[22]&7}, ${i.vic[17]&7})`,s+=`
`,s+=`VIC Bank: $${a(r,4)} Scrn: $${a(l,4)} `,p?s+=`Bitmap: $${a(o&57344,4)}`:C?s+=`Char: ROM $${a(o,4)}`:s+=`Char: $${a(o,4)}`,s+=`
`,s+=f(t,53248,64),s}case"SID":{let t=i.sid,s="";return s+=f(t,54272,32),s}}}setPaddleInput(e,i){e==0&&(this.lightpen_x=i),e==1&&(this.lightpen_y=i);let t=22,s=36,r=228,o=220,l=d(0,255,(this.lightpen_x-t)/(r-t)*160+24),p=d(0,255,(this.lightpen_y-s)/(o-s)*200+50);this.exports.machine_set_mouse(this.sys,l,p)}};var R=[{id:"helloc.c",name:"Hello World",category:"C"},{id:"screen_ram.c",name:"Screen RAM"},{id:"siegegame.c",name:"Siege Game"},{id:"joymove.c",name:"Sprite Movement"},{id:"sprite_collision.c",name:"Sprite Collision"},{id:"scroll1.c",name:"Scrolling (Single Buffer)"},{id:"test_setirq.c",name:"Raster Interrupts"},{id:"test_display_list.c",name:"Raster IRQ Library"},{id:"scrolling_text.c",name:"Big Scrolling Text"},{id:"side_scroller.c",name:"Side-Scrolling Game"},{id:"scroll2.c",name:"Scrolling (Double Buffer)"},{id:"scroll3.c",name:"Scrolling (Multidirectional)"},{id:"scroll4.c",name:"Scrolling (Color RAM Buffering)"},{id:"scroll5.c",name:"Scrolling (Camera Following)"},{id:"fullscrollgame.c",name:"Full-Scrolling Game"},{id:"test_multiplex.c",name:"Sprite Retriggering"},{id:"test_multispritelib.c",name:"Sprite Multiplexing Library"},{id:"mcbitmap.c",name:"Multicolor Bitmap Mode"},{id:"testlz4.c",name:"LZ4 Bitmap Compression"},{id:"musicplayer.c",name:"Music Player"},{id:"siddemo.c",name:"SID Player Demo"},{id:"digisound.c",name:"Digi Sound Player"},{id:"climber.c",name:"Climber Game"},{id:"test_border_sprites.c",name:"Sprites in the Borders"},{id:"sprite_stretch.c",name:"Sprite Stretching"},{id:"linecrunch.c",name:"Linecrunch"},{id:"fld.c",name:"Flexible Line Distance"},{id:"plasma.c",name:"Plasma Demo"},{id:"23matches.c",name:"23 Matches"},{id:"tgidemo.c",name:"TGI Graphics Demo"},{id:"upandaway.c",name:"Up, Up and Away"},{id:"hello.dasm",name:"Hello World (DASM)",category:"Assembly"},{id:"hello.acme",name:"Hello World (ACME)"},{id:"hello.wiz",name:"Hello Wiz (Wiz)"},{id:"hello.cpp",name:"Hello Oscar64",category:"C++ (Oscar64)"},{id:"particles.cpp",name:"Fireworks"},{id:"lander.cpp",name:"Lunar Lander"}],v={main:[{name:"6510 Registers",start:0,size:2,type:"io"},{name:"BIOS Reserved",start:512,size:167},{name:"Default Screen RAM",start:1024,size:1024,type:"ram"},{name:"Cartridge ROM",start:32768,size:8192,type:"rom"},{name:"BASIC ROM",start:40960,size:8192,type:"rom"},{name:"Upper RAM",start:49152,size:4096,type:"ram"},{name:"Character ROM",start:53248,size:4096,type:"rom"},{name:"VIC-II I/O",start:53248,size:1024,type:"io"},{name:"SID",start:54272,size:1024,type:"io"},{name:"Color RAM",start:55296,size:1024,type:"io"},{name:"CIA 1",start:56320,size:256,type:"io"},{name:"CIA 2",start:56576,size:256,type:"io"},{name:"I/O 1",start:56832,size:256,type:"io"},{name:"I/O 2",start:57088,size:256,type:"io"},{name:"KERNAL ROM",start:57344,size:8192,type:"rom"}]},h=class extends y{newMachine(){return new m("c64")}getPresets(){return R}readAddress(c){return this.machine.readConst(c)}getMemoryMap(){return v}showHelp(){return"https://8bitworkshop.com/docs/platforms/c64/"}getROMExtension(c){return c&&c[0]==1&&c[1]==8?".prg":".bin"}},u=class extends M{constructor(){super(...arguments);this.getToolForFilename=S;this.getOpcodeMetadata=_}getPresets(){return R}getDefaultExtensions(){return[".c",".cpp",".o64",".acme",".xa",".ca65",".dasm",".ecs",".wiz"]}loadROM(e,i){if(!this.started)this.startModule(this.mainElement,{jsfile:"mame8bitpc.js",biosfile:"c64.zip",cfgfile:"c64.cfg",driver:"c64",width:418,height:235,romfn:"/emulator/image.crt",romdata:new Uint8Array(i),romsize:65536,extraargs:["-autoboot_delay","5","-autoboot_command",`load "$",8,1
`],preInit:function(s){}});else{this.loadROMFile(i),this.loadRegion(":quickload",i);var t=this.luacall('image:load("/emulator/image.prg")');console.log("load rom",t)}}start(){}getMemoryMap(){return v}};n.c64=h;n["c64.wasm"]=h;n["c64.mame"]=u;
//# sourceMappingURL=c64-RILK5FDC.js.map