mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-08-26 15:28:57 +00:00
8 lines
7.1 KiB
Plaintext
8 lines
7.1 KiB
Plaintext
{
|
|
"version": 3,
|
|
"sources": ["../src/platform/x86.ts"],
|
|
"sourcesContent": ["\nimport { Platform } from \"../common/baseplatform\";\nimport { PLATFORMS, RasterVideo } from \"../common/emu\";\nimport { loadScript } from \"../common/util\";\n\n// PC emulator: https://github.com/copy/v86\n\ndeclare var V86Starter : any;\ndeclare var V86 : any;\ndeclare var CPU : any;\ndeclare var fatfs : any;\n\nconst PC_PRESETS = [\n {id:'hello.asm', name:'Hello World (ASM)'},\n {id:'mandelg.asm', name:'Mandelbrot (ASM)'},\n {id:'snake.c', name:'Snake Game (C)'},\n];\n\nclass FATFSArrayBufferDriver {\n buffer : ArrayBuffer;\n data : DataView;\n sectorSize : number;\n numSectors : number;\n constructor(buffer : ArrayBuffer) {\n this.buffer = buffer;\n this.data = new DataView(this.buffer);\n this.sectorSize = 512;\n this.numSectors = this.buffer.byteLength / this.sectorSize;\n }\n readSectors(sector, dest, cb) {\n var ofs = this.sectorSize * sector;\n for (var i=0; i<dest.length; i++) {\n dest[i] = this.data.getUint8(i + ofs);\n }\n //console.log('read', sector, dest, cb);\n cb(null);\n }\n writeSectors(sector, data, cb) {\n var ofs = this.sectorSize * sector;\n for (var i=0; i<data.length; i++) {\n this.data.setUint8(i + ofs, data[i]);\n }\n //console.log('write', sector, data, cb);\n cb(null);\n }\n}\n \nclass X86PCPlatform implements Platform {\n\n mainElement : HTMLElement;\n video : RasterVideo;\n console_div : HTMLElement;\n\n emulator;\n v86;\n fda_image;\n fda_driver;\n fda_fs;\n\n constructor(mainElement) {\n //super();\n this.mainElement = mainElement;\n }\n getToolForFilename(s: string): string {\n if (s.endsWith(\".c\")) return \"smlrc\";\n return \"yasm\";\n }\n getDefaultExtension(): string {\n return \".asm\";\n }\n getPresets() {\n return PC_PRESETS;\n }\n pause(): void {\n if (this.isRunning()) this.emulator.stop();\n }\n resume(): void {\n if (!this.isRunning()) this.emulator.run();\n }\n reset() {\n this.emulator.restart();\n }\n isRunning() {\n return this.emulator.is_running();\n }\n loadROM(title: string, rom: any) {\n this.fda_fs.writeFile('main.exe', rom, {encoding:'binary'}, (e) => {\n if (e) throw e;\n else this.reset();\n });\n }\n async start() {\n await loadScript('./lib/libv86.js');\n await loadScript('./lib/fatfs.js');\n\n this.video = new RasterVideo(this.mainElement,640,480,{overscan:false});\n this.video.create();\n\n var div = document.createElement('div');\n div.classList.add('pc-console');\n div.classList.add('emuvideo');\n this.mainElement.appendChild(div);\n this.console_div = div;\n this.resize(); // set font size\n\n this.emulator = new V86Starter({\n memory_size: 2 * 1024 * 1024,\n vga_memory_size: 1 * 1024 * 1024,\n screen_container: this.mainElement,\n bios: {\n url: \"./res/seabios.bin\",\n },\n vga_bios: {\n url: \"./res/vgabios.bin\",\n },\n fda: {\n url: \"./res/freedos722.img\",\n size: 737280,\n },\n autostart: true,\n });\n return new Promise<void>( (resolve, reject) => {\n this.emulator.add_listener(\"emulator-ready\", () => {\n console.log(\"emulator ready\");\n console.log(this.emulator);\n this.v86 = this.emulator.v86;\n this.fda_image = this.v86.cpu.devices.fdc.fda_image;\n this.fda_driver = new FATFSArrayBufferDriver(this.fda_image.buffer);\n this.fda_fs = fatfs.createFileSystem(this.fda_driver);\n resolve();\n });\n });\n }\n\n resize() {\n // set font size proportional to window width\n var charwidth = $(this.console_div).width() * 1.7 / 80;\n $(this.console_div).css('font-size', charwidth+'px');\n }\n\n getDebugTree() {\n return this.v86;\n }\n readAddress(addr:number) {\n return this.v86.cpu.mem8[addr];\n }\n getMemoryMap() { return { main:[\n {name:'Real Mode IVT',start:0x0,size:0x400,type:'ram'},\n {name:'BIOS Data Area',start:0x400,size:0x100,type:'ram'},\n {name:'User RAM',start:0x500,size:0x80000-0x500,type:'ram'},\n {name:'Extended BIOS Data Area',start:0x80000,size:0x20000,type:'ram'},\n {name:'Video RAM',start:0xa0000,size:0x20000,type:'ram'},\n {name:'Video BIOS',start:0xc0000,size:0x8000,type:'rom'},\n {name:'BIOS Expansions',start:0xc8000,size:0x28000,type:'rom'},\n {name:'PC BIOS',start:0xf0000,size:0x10000,type:'rom'},\n ] } };\n\n getROMExtension(rom : Uint8Array) {\n return \".exe\";\n }\n}\n\nPLATFORMS['x86'] = X86PCPlatform;\n"],
|
|
"mappings": "kFAYA,GAAM,GAAa,CACf,CAAC,GAAG,YAAa,KAAK,qBACtB,CAAC,GAAG,cAAe,KAAK,oBACxB,CAAC,GAAG,UAAW,KAAK,mBAGxB,OAA6B,CAKzB,YAAY,EAAsB,CAC9B,KAAK,OAAS,EACd,KAAK,KAAO,GAAI,UAAS,KAAK,QAC9B,KAAK,WAAa,IAClB,KAAK,WAAa,KAAK,OAAO,WAAa,KAAK,WAEpD,YAAY,EAAQ,EAAM,EAAI,CAE1B,OADI,GAAM,KAAK,WAAa,EACnB,EAAE,EAAG,EAAE,EAAK,OAAQ,IACzB,EAAK,GAAK,KAAK,KAAK,SAAS,EAAI,GAGrC,EAAG,MAEP,aAAa,EAAQ,EAAM,EAAI,CAE3B,OADI,GAAM,KAAK,WAAa,EACnB,EAAE,EAAG,EAAE,EAAK,OAAQ,IACzB,KAAK,KAAK,SAAS,EAAI,EAAK,EAAK,IAGrC,EAAG,QAIX,OAAwC,CAYpC,YAAY,EAAa,CAErB,KAAK,YAAc,EAEvB,mBAAmB,EAAmB,CAClC,MAAI,GAAE,SAAS,MAAc,QACtB,OAEX,qBAA8B,CAC1B,MAAO,OAEX,YAAa,CACT,MAAO,GAEX,OAAc,CACV,AAAI,KAAK,aAAa,KAAK,SAAS,OAExC,QAAe,CACX,AAAK,KAAK,aAAa,KAAK,SAAS,MAEzC,OAAQ,CACJ,KAAK,SAAS,UAElB,WAAY,CACR,MAAO,MAAK,SAAS,aAEzB,QAAQ,EAAe,EAAU,CAC7B,KAAK,OAAO,UAAU,WAAY,EAAK,CAAC,SAAS,UAAW,AAAC,GAAM,CAC/D,GAA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