1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-15 14:07:16 +00:00
8bitworkshop/gen/sound_konami-SADT3JNV.js.map

8 lines
6.0 KiB
Plaintext

{
"version": 3,
"sources": ["../src/platform/sound_konami.ts"],
"sourcesContent": ["\nimport { Platform, BaseZ80Platform } from \"../common/baseplatform\";\nimport { PLATFORMS, RAM, newAddressDecoder, padBytes, noise, setKeyboardFromMap, AnimationTimer, RasterVideo, Keys, makeKeycodeMap } from \"../common/emu\";\nimport { hex } from \"../common/util\";\n\n// from TSS\ndeclare var MasterChannel, AudioLooper, PsgDeviceChannel;\n\nvar KONAMISOUND_PRESETS = [\n];\n\nvar KonamiSoundPlatform = function(mainElement) {\n this.__proto__ = new (BaseZ80Platform as any)();\n\n var cpu, ram, rom, membus, iobus;\n var audio, master;\n var video, timer;\n var interruptPending = 0;\n var psgRegister = 0;\n var psg;\n\n var cpuFrequency = 14318000/8;\n var ioTimerFrequency = 1789750 / 1280;\n var cpuCyclesPerFrame = cpuFrequency/60;\n var cpuCyclesPerTimer = cpuFrequency/ioTimerFrequency;\n\n this.getPresets = function() {\n return KONAMISOUND_PRESETS;\n }\n\n this.start = function() {\n ram = new RAM(0x400);\n membus = {\n read: newAddressDecoder([\n\t\t\t\t[0x0000, 0x3fff, 0x3fff, function(a) { return rom ? rom[a] : null; }],\n\t\t\t\t[0x4000, 0x5fff, 0x3ff, function(a) { return ram.mem[a]; }]\n\t\t\t]),\n\t\t\twrite: newAddressDecoder([\n\t\t\t\t[0x4000, 0x5fff, 0x3ff, function(a,v) { ram.mem[a] = v; }],\n\t\t\t]),\n isContended: function() { return false; },\n };\n iobus = {\n read: function(addr) {\n if (addr & 0x40) {\n if (psgRegister == 0xf) { // timer\n var bit = (cpu.getTstates() / cpuCyclesPerTimer) & 1;\n return bit ? 0xff : 0x00; // 0x00, 0x10, 0x20, 0x30, 0x40, 0x90, 0xa0, 0xb0, 0xa0, 0xd0\n }\n return psg.readRegister(psgRegister) & 0xff;\n }\n return 0;\n \t},\n \twrite: function(addr, val) {\n if (addr & 0x80) {\n psgRegister = val & 0xf;\n //console.log('PSG reg', psgRegister);\n }\n if (addr & 0x40) {\n psg.writeRegisterAY(psgRegister, val & 0xff);\n //console.log('PSG write', psgRegister, val);\n }\n \t}\n };\n this.readAddress = membus.read;\n cpu = this.newCPU(membus, iobus);\n psg = new PsgDeviceChannel();\n master = new MasterChannel();\n psg.setMode(PsgDeviceChannel.MODE_SIGNED);\n psg.setDevice(PsgDeviceChannel.DEVICE_AY_3_8910);\n master.addChannel(psg);\n audio = new AudioLooper(512);\n audio.setChannel(master);\n //audio = new SampleAudio(psg.sampleRate);\n video = new RasterVideo(mainElement,256,256);\n video.create();\n video.setKeyboardEvents(function(key,code,flags) {\n var intr = (key-49);\n if (intr >= 0 && (flags & 1)) {\n psg.writeRegister(14, intr);\n psg.writeRegister(15, 0x80);\n cpu.setIFF1(1);\n cpu.requestInterrupt(0x38);\n /*\n console.log(cpu.saveState());\n console.log(hex(intr * 8), cpu.getIFF1(), cpu.getIM());\n cpu.runFrame(cpu.getTstates() + 1);\n console.log(cpu.saveState());\n */\n }\n });\n timer = new AnimationTimer(60, () => {\n\t\t\tif (!this.isRunning())\n\t\t\t\treturn;\n var debugCond = this.getDebugCallback();\n var targetTstates = cpu.getTstates() + cpuCyclesPerFrame;\n if (debugCond) {\n while (cpu.getTstates() < targetTstates) {\n if (debugCond && debugCond()) { debugCond = null; }\n cpu.runFrame(cpu.getTstates() + 1);\n }\n } else {\n cpu.runFrame(targetTstates);\n }\n });\n }\n\n this.loadROM = function(title, data) {\n rom = padBytes(data, 0x4000);\n cpu.reset();\n }\n\n this.loadState = function(state) {\n cpu.loadState(state.c);\n ram.mem.set(state.b);\n }\n this.saveState = function() {\n return {\n c:this.getCPUState(),\n b:ram.mem.slice(0),\n };\n }\n this.getCPUState = function() {\n return cpu.saveState();\n }\n\n this.isRunning = function() {\n return timer && timer.isRunning();\n }\n this.pause = function() {\n timer.stop();\n //audio.stop();\n }\n this.resume = function() {\n timer.start();\n audio.activate();\n }\n this.reset = function() {\n cpu.reset();\n if (!this.getDebugCallback()) cpu.setTstates(0); // TODO?\n }\n}\n\nPLATFORMS['sound_konami'] = KonamiSoundPlatform;\n"],
"mappings": "+IAQA,GAAI,GAAsB,GAGtB,EAAsB,SAAS,EAAa,CAC9C,KAAK,UAAY,GAAK,GAEtB,GAAI,GAAK,EAAK,EAAK,EAAQ,EACvB,EAAO,EACP,EAAO,EACP,EAAmB,EACnB,EAAc,EACd,EAEA,EAAe,QAAS,EACxB,EAAmB,QAAU,KAC7B,EAAoB,EAAa,GACjC,EAAoB,EAAa,EAErC,KAAK,WAAa,UAAW,CAC3B,MAAO,IAGT,KAAK,MAAQ,UAAW,CACtB,EAAM,GAAI,GAAI,MACd,EAAS,CACP,KAAM,EAAkB,CAC1B,CAAC,EAAQ,MAAQ,MAAQ,SAAS,EAAG,CAAE,MAAO,GAAM,EAAI,GAAK,OAC7D,CAAC,MAAQ,MAAQ,KAAQ,SAAS,EAAG,CAAE,MAAO,GAAI,IAAI,OAEvD,MAAO,EAAkB,CACxB,CAAC,MAAQ,MAAQ,KAAQ,SAAS,EAAE,EAAG,CAAE,EAAI,IAAI,GAAK,MAEpD,YAAa,UAAW,CAAE,MAAO,KAEnC,EAAQ,CACN,KAAM,SAAS,EAAM,CACnB,GAAI,EAAO,GAAM,CACf,GAAI,GAAe,GAAK,CACtB,GAAI,GAAO,EAAI,aAAe,EAAqB,EACnD,MAAO,GAAM,IAAO,EAEtB,MAAO,GAAI,aAAa,GAAe,IAEzC,MAAO,IAEV,MAAO,SAAS,EAAM,EAAK,CACxB,AAAI,EAAO,KACT,GAAc,EAAM,IAGlB,EAAO,IACT,EAAI,gBAAgB,EAAa,EAAM,OAK7C,KAAK,YAAc,EAAO,KAC1B,EAAM,KAAK,OAAO,EAAQ,GAC1B,EAAM,GAAI,kBACV,EAAS,GAAI,eACb,EAAI,QAAQ,iBAAiB,aAC7B,EAAI,UAAU,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