import{J as l,r as p}from"./chunk-ULPRULB6.js";import{J as i,O as o}from"./chunk-RXF2JDJ3.js";import"./chunk-WAARL7ET.js";var m=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,64,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],c=class extends p{constructor(){super(...arguments);this.numTotalScanlines=312;this.cpuCyclesPerLine=224;this.joymask0=0;this.runaddr=16384}loadROM(t){let e=new Uint8Array(t.length+m.length);e.set(m,0),e[24]=t.length&255,e[25]=t.length>>8,e[26]=this.runaddr&255,e[27]=this.runaddr>>8,e.set(t,m.length),super.loadROM(e)}reset(){if(super.reset(),this.exports.machine_exec(this.sys,1e6),this.romptr&&this.romlen){this.exports.machine_load_rom(this.sys,this.romptr,this.romlen);for(var t=0;t<1e5&&this.getPC()!=this.runaddr;t++)this.exports.machine_tick(this.sys)}}advanceFrame(t){var e=this.getRasterY(),r=Math.floor((this.numTotalScanlines-e)*(4e6/50)/this.numTotalScanlines),s=this.probe!=null;return s&&this.exports.machine_reset_probe_buffer(),r=super.advanceFrameClock(t,r),s&&this.copyProbeData(),r}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,e=t[9]+(t[8]<<8),r=t[10]+(t[11]<<8),s=t[12]+(t[13]<<8),a=t[14]+(t[15]<<8),x=t[24]+(t[25]<<8),f=t[26]+(t[27]<<8),u=t[28]+(t[29]<<8),h=t[34]+(t[35]<<8),_=t[36]+(t[37]<<8);return{PC:h,SP:x,AF:e,BC:a,DE:s,HL:r,IX:u,IY:f,IR:_,o:this.readConst(h)}}saveState(){return this.exports.machine_save_state(this.sys,this.stateptr),{c:this.getCPUState(),state:this.statearr.slice(0)}}loadState(t){this.statearr.set(t.state),this.exports.machine_load_state(this.sys,this.stateptr)}getVideoParams(){return{width:768,height:272,overscan:!0,videoFrequency:50,aspect:1.3}}setKeyInput(t,e,r){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==65&&(t=65,a=4),t==87&&(t=87,a=1),t==68&&(t=68,a=8),t==83&&(t=83,a=2),t==69&&(a=16),t==113&&(t=241),t==115&&(t=243),t==119&&(t=245),t==121&&(t=247),r&o.KeyDown?(this.exports.machine_key_down(this.sys,t),this.joymask0|=s):r&o.KeyUp&&(this.exports.machine_key_up(this.sys,t),this.joymask0&=~s)}}};var v=[{id:"hello.asm",name:"Hello World (ASM)"},{id:"easy_stdio_boxes.c",name:"Standard I/O (C)"},{id:"easy_mode_strings.c",name:"Video Modes (C)"},{id:"easy_random.c",name:"Random Numbers (C)"},{id:"easy_sprites.c",name:"Keyboard + Sprites (C)"},{id:"medium_scrolling.c",name:"Scrolling Text (C)"},{id:"siegegame.c",name:"Siege Game (C)"},{id:"music.c",name:"Music Player (C)"}],C={main:[{name:"BIOS",start:0,size:16384,type:"rom"},{name:"Screen RAM",start:49152,size:16384,type:"ram"}]},n=class extends l{newMachine(){return new c("cpc")}getPresets(){return v}getDefaultExtension(){return".asm"}readAddress(t){return this.machine.readConst(t)}getMemoryMap(){return C}showHelp(){return"http://lronaldo.github.io/cpctelera/files/readme-txt.html"}};i["cpc.6128"]=n;i["cpc.464"]=n;i["cpc.kcc"]=n; //# sourceMappingURL=cpc-Y7H77AJC.js.map