{ "version": 3, "sources": ["../src/machine/vic20.ts", "../src/platform/vic20.ts"], "sourcesContent": ["\n//// WASM Machine\n\n// http://www.zimmers.net/anonftp/pub/cbm/documents/chipdata/VIC-I.txt\n// http://www.zimmers.net/anonftp/pub/cbm/maps/Vic20.MemoryMap.txt\n// http://sleepingelephant.com/denial/wiki/index.php/Autostart\n\nimport { Machine } from \"../common/baseplatform\";\nimport { Probeable, TrapCondition } from \"../common/devices\";\nimport { KeyFlags } from \"../common/emu\";\nimport { hex } from \"../common/util\";\nimport { BaseWASMMachine } from \"../common/wasmplatform\";\n\nexport class VIC20_WASMMachine extends BaseWASMMachine implements Machine, Probeable {\n\n numTotalScanlines = 312;\n cpuCyclesPerLine = 71;\n videoOffsetBytes = -24 * 4;\n\n prgstart : number;\n joymask0 = 0;\n joymask1 = 0;\n\n getBIOSLength() { return 0x5000 };\n\n loadBIOS(srcArray: Uint8Array) {\n super.loadBIOS(srcArray);\n }\n reset() {\n super.reset();\n // clear keyboard\n for (var ch=0; ch<128; ch++) {\n this.setKeyInput(ch, 0, KeyFlags.KeyUp);\n }\n // load rom\n if (this.romptr && this.romlen) {\n let rom = this.romarr;\n this.exports.machine_load_rom(this.sys, this.romptr, this.romlen);\n let iscart = rom[4+2]==0x41 && rom[5+2]==0x30 && rom[6+2]==0xC3 && rom[7+2]==0xC2 && rom[8+2]==0xCD;\n if (!iscart) {\n this.prgstart = rom[0] + (rom[1]<<8); // get load address\n // look for BASIC program start\n if (this.prgstart == 0x1001) {\n this.prgstart = rom[2] + (rom[3]<<8) + 2; // point to after BASIC program\n console.log(\"prgstart\", hex(this.prgstart));\n }\n // is program loaded into RAM?\n if (this.prgstart < 0x8000) {\n // advance BIOS a few frames\n this.exports.machine_exec(this.sys, 500000);\n // type in command (SYS 2061)\n var cmd = \"SYS \"+this.prgstart+\"\\r\";\n console.log(cmd);\n for (var i=0; i implements Platform {\n\n newMachine() { return new VIC20_WASMMachine('vic20'); }\n\n getPresets() { return VIC20_PRESETS; }\n getDefaultExtension() { return \".c\"; };\n readAddress(a) { return this.machine.readConst(a); }\n getMemoryMap() { return VIC20_MEMORY_MAP; }\n showHelp() {\n return \"https://8bitworkshop.com/docs/platforms/vic20/\";\n }\n getROMExtension(rom:Uint8Array) { \n /*\n if (rom && rom[0] == 0x00 && rom[1] == 0x80 && rom[2+4] == 0xc3 && rom[2+5] == 0xc2) return \".crt\";\n */\n if (rom && rom[0] == 0x01 && rom[1] == 0x08) return \".prg\";\n else return \".bin\";\n }\n}\n\n// VIC20 MAME platform (TODO)\nabstract class VIC20MAMEPlatform extends BaseMAME6502Platform {\n getPresets() { return VIC20_PRESETS; }\n getToolForFilename = getToolForFilename_6502;\n getOpcodeMetadata = getOpcodeMetadata_6502;\n getDefaultExtension() { return \".c\"; }\n loadROM(title, data) {\n if (!this.started) {\n this.startModule(this.mainElement, {\n jsfile:'mame8bitpc.js',\n biosfile:'vic20.zip',\n cfgfile:'vic20.cfg',\n driver:'vic20',\n width:418,\n height:235,\n romfn:'/emulator/image.crt',\n romdata:new Uint8Array(data),\n romsize:0x10000,\n extraargs: ['-autoboot_delay','5','-autoboot_command','load \"$\",8,1\\n'],\n preInit:function(_self) {\n },\n });\n } else {\n this.loadROMFile(data);\n this.loadRegion(\":quickload\", data);\n var result = this.luacall(`image:load(\"/emulator/image.prg\")`)\n console.log('load rom', result);\n //this.loadRegion(\":exp:standard\", data);\n }\n }\n start() {\n }\n getMemoryMap() { return VIC20_MEMORY_MAP; }\n}\n\n\nPLATFORMS['vic20'] = VIC20WASMPlatform;\nPLATFORMS['vic20.wasm'] = VIC20WASMPlatform;\nPLATFORMS['vic20.mame'] = VIC20MAMEPlatform;\n"], "mappings": "uLAaO,mBAAgC,EAA8C,CAA9E,aAbP,CAaO,oBAEL,uBAAoB,IACpB,sBAAmB,GACnB,sBAAmB,IAAM,EAGzB,cAAW,EACX,cAAW,EAEX,eAAgB,CAAE,MAAO,OAEzB,SAAS,EAAsB,CAC7B,MAAM,SAAS,GAEjB,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