{ "version": 3, "sources": ["../src/machine/devel.ts", "../src/platform/devel.ts"], "sourcesContent": ["\nimport { MOS6502 } from \"../common/cpu/MOS6502\";\nimport { BasicHeadlessMachine, HasSerialIO, SerialIOInterface } from \"../common/devices\";\nimport { padBytes, newAddressDecoder } from \"../common/emu\"; // TODO\n\nconst INPUT_HALTED = 31;\n\nexport class Devel6502 extends BasicHeadlessMachine implements HasSerialIO {\n\n cpuFrequency = 1000000;\n defaultROMSize = 0x8000;\n \n cpu = new MOS6502();\n ram = new Uint8Array(0x4000);\n rom : Uint8Array;\n serial : SerialIOInterface;\n\n constructor() {\n super();\n this.connectCPUMemoryBus(this);\n }\n \n connectSerialIO(serial: SerialIOInterface) {\n this.serial = serial;\n }\n\n read = newAddressDecoder([\n [0x0000, 0x3fff, 0x3fff, (a) => { return this.ram[a]; }],\n [0x4000, 0x4000, 0xffff, (a) => { return this.serial.byteAvailable() ? 0x80 : 0 }],\n [0x4001, 0x4001, 0xffff, (a) => { return this.serial.recvByte() }],\n [0x4002, 0x4002, 0xffff, (a) => { return this.serial.clearToSend() ? 0x80 : 0 }],\n [0x8000, 0xffff, 0x7fff, (a) => { return this.rom && this.rom[a]; }],\n ]);\n \n write = newAddressDecoder([\n [0x0000, 0x3fff, 0x3fff, (a,v) => { this.ram[a] = v; }],\n [0x4003, 0x4003, 0xffff, (a,v) => { return this.serial.sendByte(v) }],\n [0x400f, 0x400f, 0xffff, (a,v) => { this.inputs[INPUT_HALTED] = 1; }],\n ]);\n \n readConst(a:number) : number {\n return this.read(a);\n }\n\n advanceFrame(trap) : number {\n var clock = 0;\n while (clock < this.cpuFrequency/60) {\n if (trap && trap()) break;\n clock += this.advanceCPU();\n }\n return clock;\n }\n\n advanceCPU() {\n if (this.isHalted()) return 1;\n var n = super.advanceCPU();\n if (this.serial) this.serial.advance(n);\n return n;\n }\n\n reset() {\n this.inputs[INPUT_HALTED] = 0;\n super.reset();\n if (this.serial) this.serial.reset();\n }\n\n isHalted() { return this.inputs[INPUT_HALTED] != 0; }\n}\n\n", "\nimport { Platform } from \"../common/baseplatform\";\nimport { EmuHalt, PLATFORMS } from \"../common/emu\";\nimport { Devel6502 } from \"../machine/devel\";\nimport { Base6502MachinePlatform } from \"../common/baseplatform\";\nimport { SerialIOInterface } from \"../common/devices\";\nimport { byteArrayToString, convertDataToUint8Array } from \"../common/util\";\nimport { TeleType } from \"../common/teletype\";\nimport { haltEmulation } from \"../ide/ui\";\n\nvar DEVEL_6502_PRESETS = [\n {id:'hello.dasm', name:'Hello World (ASM)'},\n];\n\nclass SerialInOutViewer {\n div : HTMLElement;\n tty : TeleType;\n \n constructor(div: HTMLElement) {\n div.style.overflowY = 'auto';\n var gameport = $('
Serial Output
').appendTo(gameport);\n var windowport = $('