mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-09-07 15:54:26 +00:00
8 lines
9.5 KiB
Plaintext
8 lines
9.5 KiB
Plaintext
|
{
|
||
|
"version": 3,
|
||
|
"sources": ["../src/machine/vicdual.ts", "../src/platform/vicdual.ts"],
|
||
|
"sourcesContent": ["\nimport { Z80, Z80State } from \"../common/cpu/ZilogZ80\";\nimport { BasicScanlineMachine } from \"../common/devices\";\nimport { KeyFlags, newAddressDecoder, padBytes, Keys, makeKeycodeMap, newKeyboardHandler } from \"../common/emu\";\nimport { TssChannelAdapter, MasterAudio, AY38910_Audio } from \"../common/audio\";\n\nconst CARNIVAL_KEYCODE_MAP = makeKeycodeMap([\n [Keys.A, 2, -0x20],\n [Keys.B, 2, -0x40],\n [Keys.LEFT, 1, -0x10],\n [Keys.RIGHT, 1, -0x20],\n [Keys.UP, 1, -0x40],\n [Keys.DOWN, 1, -0x80],\n [Keys.START, 2, -0x10],\n [Keys.P2_START, 3, -0x20],\n [Keys.SELECT, 3, 0x8],\n]);\n\nconst XTAL = 15468000.0;\nconst scanlinesPerFrame = 0x106;\nconst vblankStart = 0xe0;\nconst vsyncStart = 0xec;\nconst vsyncEnd = 0xf0;\nconst cpuFrequency = XTAL / 8;\nconst hsyncFrequency = XTAL / 3 / scanlinesPerFrame;\nconst vsyncFrequency = hsyncFrequency / 0x148;\nconst cpuCyclesPerLine = cpuFrequency / hsyncFrequency;\nconst timerFrequency = 500; // input 2 bit 0x8\nconst cyclesPerTimerTick = cpuFrequency / (2 * timerFrequency);\nconst audioOversample = 2;\nconst audioSampleRate = 60 * scanlinesPerFrame; // why not hsync?\n\nexport class VicDual extends BasicScanlineMachine {\n\n cpuFrequency = XTAL / 8; // MHz\n canvasWidth = 256;\n numTotalScanlines = 262;\n numVisibleScanlines = 224;\n defaultROMSize = 0x4040;\n sampleRate = audioSampleRate * audioOversample;\n cpuCyclesPerLine = cpuCyclesPerLine|0;\n rotate = -90;\n \n cpu: Z80 = new Z80();\n ram = new Uint8Array(0x1000);\n psg: AY38910_Audio;\n display: VicDualDisplay;\n audioadapter;\n\n constructor() {\n super();\n this.connectCPUMemoryBus(this);\n this.connectCPUIOBus(this.newIOBus());\n this.inputs.set([0xff, 0xff, 0xff, 0xff ^ 0x8]); // most things active low\n this.display = new VicDualDisplay();\n this.handler = newKeyboardHandler(this.inputs, CARNIVAL_KEYCODE_MAP, this.getKeyboardFunction());\n this.psg = new AY38910_Audio(new MasterAudio());\n this.audioadapter = new TssChannelAdapter(this.psg.psg, audioOversample, this.sampleRate);\n }\n\n getKeyboardFunction() {\n return (o) => {\n // reset when coin inserted\n if (o.index == 3 && o.mask == 0x8) {\n this.cpu.reset();\n console.log(\"coin inserted\");\n console.log(this.inputs)\n }\n }\n };\n\n read = newAddressDecoder([\n [0x0000, 0x7fff, 0x3fff, (a) => { return this.rom ? this.rom[a] : null; }],\n [0x8000, 0xffff, 0x0fff, (a) => { return this.ram[a]; }],\n ]);\n \n write = newAddressDecoder([\n [0x8000, 0xffff, 0x0fff, (a, v) => { this.ram[a] = v; }],\n ]);\n\n newIOBus() {\n return {\n read: (addr) => {\n return this.inputs[addr & 3];\n },\n write: (addr, val) => {\n if (addr & 0x1) { this.psg.selectRegister(val & 0xf); }; // audio 1\n if (addr & 0x2) { this.psg.setData(val); }; // audio 2\n if (addr & 0x8) { }; // TODO: assert coin status\n if (addr & 0x40) { this.display.palbank = val & 3; }; // palette\n }\n };\n }\n\n reset() {\n super.reset();\n this.psg.reset();\n }\n\n startScanline() {\n this.inputs[2] &= ~0x8;\n this.inputs[2] |= ((this.frameCycles / cyclesPerTimerTick) & 1) << 3;\n if (this.scanline == vblankStart) this.inputs[1] |= 0x8;\n if (this.scanline == vsyncEnd) this.inputs[1] &= ~0x8;\n this.audio && this.audioadapter.generate(this.audio);\n }\n\n drawScanline() {\n this.display.drawScanline(this.ram, this.pixels, this.scanline);\n }\n\n loadROM(data) {\n super.loadROM(data);\n if (data.length >= 0x4020 && (data[0x4000] || data[0x401f])) {\n this.display.colorprom = data.slice(0x4000, 0x4020);\n }\n }\n\n loadState(state) {\n super.loadState(state);\n this.display.palbank = state.pb;\n }\n \n saveState() {\n var state = super.saveState();\n state['pb'] = this.display.palbank;\n return state;\n }\n}\n\nclass VicDualDisplay {\n palbank: number = 0;\n\n palette = [\n 0xff000000, // black\n 0xff
|
||
|
"mappings": "uMAMA,GAAM,GAAuB,EAAe,CAC1C,CAAC,EAAK,EAAU,EAAG,KACnB,CAAC,EAAK,EAAU,EAAG,KACnB,CAAC,EAAK,KAAU,EAAG,KACnB,CAAC,EAAK,MAAU,EAAG,KACnB,CAAC,EAAK,GAAU,EAAG,KACnB,CAAC,EAAK,KAAU,EAAG,MACnB,CAAC,EAAK,MAAU,EAAG,KACnB,CAAC,EAAK,SAAU,EAAG,KACnB,CAAC,EAAK,OAAU,EAAG,KAGf,EAAO,QACP,EAAoB,IACpB,EAAc,IAEpB,GAAM,GAAW,IACX,EAAe,EAAO,EACtB,EAAiB,EAAO,EAAI,EAC5B,EAAiB,EAAiB,IAClC,EAAmB,EAAe,EAClC,EAAiB,IACjB,EAAqB,EAAgB,GAAI,GACzC,EAAkB,EAClB,EAAkB,GAAK,EAEtB,eAAsB,EAAqB,CAiBhD,aAAc,CACZ,QAhBF,kBAAe,EAAO,EACtB,iBAAc,IACd,uBAAoB,IACpB,yBAAsB,IACtB,oBAAiB,MACjB,gBAAa,EAAkB,EAC/B,sBAAmB,EAAiB,EACpC,YAAS,IAET,SAAW,GAAI,GACf,SAAM,GAAI,YAAW,MA2BrB,UAAO,EAAkB,CACvB,CAAC,EAAQ,MAAQ,MAAQ,AAAC,GAAe,KAAK,IAAM,KAAK,IAAI,GAAK,MAClE,CAAC,MAAQ,MAAQ,KAAQ,AAAC,GAAe,KAAK,IAAI,MAGpD,WAAQ,EAAkB,CACxB,CAAC,MAAQ,MAAQ,KAAQ,CAAC,EAAG,IAAM,CAAE,KAAK,IAAI,GAAK,MA1BnD,KAAK,oBAAoB,MACzB,K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