8bitworkshop/gen/vic20-PC2ZVKOB.js

4 lines
5.3 KiB
JavaScript

import{a as f}from"./chunk-ZYQJTLXH.js";import{B as l,I as C,r as F,y as p}from"./chunk-42IVW2OL.js";import{J as i,O as o,g as n}from"./chunk-S4FPTY4A.js";import"./chunk-RQFURXHW.js";var m=class extends F{constructor(){super(...arguments);this.numTotalScanlines=312;this.cpuCyclesPerLine=71;this.videoOffsetBytes=-24*4;this.joymask0=0;this.joymask1=0}getBIOSLength(){return 20480}loadBIOS(t){super.loadBIOS(t)}async fetchBIOS(){let t=new Uint8Array(20480);t.set(u,t.length-u.length),this.allocateBIOS(t),this.loadBIOS(new Uint8Array(t))}reset(){super.reset();for(var t=0;t<128;t++)this.setKeyInput(t,0,o.KeyUp);if(this.romptr&&this.romlen){let r=this.romarr;if(this.exports.machine_load_rom(this.sys,this.romptr,this.romlen),r[4+2]==65&&r[5+2]==48&&r[6+2]==195&&r[7+2]==194&&r[8+2]==205){for(var a=this.romarr[2+2]+this.romarr[3+2]*256,e=0;e<1e4&&this.getPC()!=a;e++)this.exports.machine_tick(this.sys);console.log("cart",e,n(a))}else if(this.prgstart=r[0]+(r[1]<<8),this.prgstart==4097&&(this.prgstart=r[2]+(r[3]<<8)+2,console.log("prgstart",n(this.prgstart))),this.prgstart<32768){this.exports.machine_exec(this.sys,5e5);var x="SYS "+this.prgstart+"\r";console.log(x);for(var e=0;e<x.length;e++){var s=x.charCodeAt(e);this.exports.machine_exec(this.sys,1e4),this.exports.machine_exec(this.sys,1e4),this.exports.machine_key_down(this.sys,s),this.exports.machine_exec(this.sys,1e4),this.exports.machine_exec(this.sys,1e4),this.exports.machine_key_up(this.sys,s)}for(var e=0;e<1e4&&this.getPC()!=this.prgstart;e++)this.exports.machine_tick(this.sys)}}}advanceFrame(t){var x=this.getRasterY(),e=Math.floor((this.numTotalScanlines-x)*22152/this.numTotalScanlines),s=this.probe!=null;return s&&this.exports.machine_reset_probe_buffer(),e=super.advanceFrameClock(t,e),s&&this.copyProbeData(),e}getRasterY(){return this.exports.machine_get_raster_line(this.sys)}getRasterCanvasPosition(){return{x:-1,y:this.getRasterY()-14}}getCPUState(){this.exports.machine_save_cpu_state(this.sys,this.cpustateptr);var t=this.cpustatearr,x=t[2]+(t[3]<<8);return{PC:x,SP:t[9],A:t[6],X:t[7],Y:t[8],C:t[10]&1,Z:t[10]&2,I:t[10]&4,D:t[10]&8,V:t[10]&64,N:t[10]&128,o:this.readConst(x)}}saveState(){return this.exports.machine_save_state(this.sys,this.stateptr),{c:this.getCPUState(),state:this.statearr.slice(0),ram:this.statearr.slice(18640,18640+512)}}loadState(t){this.statearr.set(t.state),this.exports.machine_load_state(this.sys,this.stateptr)}getVideoParams(){return{width:232,height:272,overscan:!0,videoFrequency:50,aspect:1.5}}setKeyInput(t,x,e){if(!(t==16||t==17||t==18||t==224)){var s=0,a=0;t==37&&(t=8,s=4),t==38&&(t=11,s=1),t==39&&(t=9,s=8),t==40&&(t=10,s=2),t==32&&(s=16),t==113&&(t=241),t==115&&(t=243),t==119&&(t=245),t==121&&(t=247),e&o.KeyDown?(this.exports.machine_key_down(this.sys,t),this.joymask0|=s,this.joymask1|=a):e&o.KeyUp&&(this.exports.machine_key_up(this.sys,t),this.joymask0&=~s,this.joymask1&=~a),this.exports.vic20_joystick(this.sys,this.joymask0,this.joymask1)}}},u=[162,16,160,145,96,113,255,113,255,92,255,162,255,120,154,216,108,0,160,162,69,160,255,24,120,108,24,3,72,138,72,152,72,173,29,145,16,3,108,2,160,76,108,255,104,168,104,170,104,64,72,138,72,152,72,186,189,4,1,41,16,240,3,108,22,3,108,20,3,255,255,255,255,255,76,83,255,76,68,255,76,68,255,76,68,255,76,68,255,76,68,255,76,68,255,76,68,255,76,68,255,76,68,255,76,68,255,76,68,255,76,68,255,76,68,255,76,68,255,76,68,255,76,68,255,76,68,255,108,26,3,108,28,3,108,30,3,108,32,3,108,34,3,108,36,3,108,38,3,76,68,255,76,68,255,76,68,255,76,68,255,108,40,3,108,42,3,108,44,3,76,68,255,76,68,255,76,68,255,76,64,255,255,255,255,255,88,255,75,255,114,255];var g=[{id:"hellocart.dasm",name:"Hello Cartridge (ASM)"}],d={main:[{name:"RAM",start:0,size:1024,type:"ram"},{name:"RAM",start:4096,size:4096,type:"ram"},{name:"BLK1 Cart ROM",start:8192,size:8192,type:"rom"},{name:"BLK2 Cart ROM",start:16384,size:8192,type:"rom"},{name:"BLK3 Cart ROM",start:24576,size:8192,type:"rom"},{name:"Character ROM",start:32768,size:4096,type:"rom"},{name:"I/O 1",start:36864,size:1024,type:"io"},{name:"Color RAM",start:37888,size:1024,type:"io"},{name:"I/O 2",start:38912,size:1024,type:"io"},{name:"I/O 3",start:39936,size:1024,type:"io"},{name:"BLK5 Autostart",start:40960,size:8192,type:"rom"},{name:"BASIC ROM",start:49152,size:8192,type:"rom"},{name:"KERNAL ROM",start:57344,size:8192,type:"rom"}]},h=class extends C{newMachine(){return new m("vic20")}getPresets(){return g}getDefaultExtension(){return".c"}readAddress(t){return this.machine.readConst(t)}getMemoryMap(){return d}showHelp(){return"https://8bitworkshop.com/docs/platforms/vic20/"}getROMExtension(t){return t&&t[0]==1&&t[1]==8?".prg":".bin"}},_=class extends f{constructor(){super(...arguments);this.getToolForFilename=p;this.getOpcodeMetadata=l}getPresets(){return g}getDefaultExtension(){return".c"}loadROM(t,x){if(!this.started)this.startModule(this.mainElement,{jsfile:"mame8bitpc.js",biosfile:"vic20.zip",cfgfile:"vic20.cfg",driver:"vic20",width:418,height:235,romfn:"/emulator/image.crt",romdata:new Uint8Array(x),romsize:65536,extraargs:["-autoboot_delay","5","-autoboot_command",`load "$",8,1
`],preInit:function(s){}});else{this.loadROMFile(x),this.loadRegion(":quickload",x);var e=this.luacall('image:load("/emulator/image.prg")');console.log("load rom",e)}}start(){}getMemoryMap(){return d}};i.vic20=h;i["vic20.wasm"]=h;i["vic20.mame"]=_;
//# sourceMappingURL=vic20-PC2ZVKOB.js.map