1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-18 03:05:35 +00:00
8bitworkshop/gen/atari8-TVMHGW66.js.map

8 lines
93 KiB
Plaintext

{
"version": 3,
"sources": ["../src/machine/chips/antic.ts", "../src/machine/chips/gtia.ts", "../src/machine/chips/pokey.ts", "../src/machine/atari8.ts", "../src/platform/atari8.ts"],
"sourcesContent": ["import { dumpRAM } from \"../../common/emu\";\nimport { hex, lpad, safe_extend } from \"../../common/util\";\n\n// ANTIC\n// https://www.atarimax.com/jindroush.atari.org/atanttim.html\n// http://www.virtualdub.org/blog/pivot/entry.php?id=243\n// http://www.beipmu.com/Antic_Timings.txt\n// https://user.xmission.com/~trevin/atari/antic_regs.html\n// https://user.xmission.com/~trevin/atari/antic_insns.html\n// http://www.atarimuseum.com/videogames/consoles/5200/conv_to_5200.html\n// https://www.virtualdub.org/downloads/Altirra%20Hardware%20Reference%20Manual.pdf\n\nconst PF_LEFT = [0, 25, 17, 9];\nconst PF_RIGHT = [0, 25 + 64, 17 + 80, 9 + 96];\n\nconst DMACTL = 0;\nconst CHACTL = 1;\nconst DLISTL = 2;\nconst DLISTH = 3;\nconst HSCROL = 4;\nconst VSCROL = 5;\nconst PMBASE = 7;\nconst CHBASE = 9;\nconst WSYNC = 10;\nconst VCOUNT = 11;\nconst PENH = 12;\nconst PENV = 13;\nconst NMIEN = 14;\nconst NMIRES = 15;\nconst NMIST = 15;\n\nconst PFNONE = 0;\nconst PFNARROW = 1;\nconst PFNORMAL = 2;\nconst PFWIDE = 3;\n\nconst NMIST_CYCLE = 12;\nconst NMI_CYCLE = 24;\nconst WSYNC_CYCLE = 212;\n\nconst ANTIC_LEFT = 17 - 4; // gtia 34, 4 cycle delay\nconst ANTIC_RIGHT = 110 - 4; // gtia 221, 4 cycle delay\nconst LAST_DMA_H = 105; // last DMA cycle\n\nconst MODE_LINES = [0, 0, 8, 10, 8, 16, 8, 16, 8, 4, 4, 2, 1, 2, 1, 1];\n// how many bits before DMA clock repeats?\nconst MODE_PERIOD = [0, 0, 2, 2, 2, 2, 4, 4, 8, 4, 4, 4, 4, 2, 2, 2];\nconst MODE_YPERIOD = [0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 2, 1, 0, 0, 0, 0];\n//const MODE_BPP = [0, 0, 1, 1, 2, 2, 1, 1, 2, 1, 2, 1, 1, 2, 2, 1];\n// how many color clocks / pixel * 2\nexport const MODE_SHIFT = [0, 0, 1, 1, 2, 2, 2, 2, 8, 4, 4, 2, 2, 2, 2, 1];\n\nexport class ANTIC {\n read: (address: number) => number;\t// bus read function\n nmi: () => void; // generate NMI\n\n regs = new Uint8Array(0x10);\t\t\t\t// registers\n\n left: number;\n right: number;\t\t\t\t\t// left/right clocks for mode\n\n dma_enabled: boolean = false;\n dliop: number = 0; // dli operation\n mode: number = 0;\t\t\t// current mode\n jmp = false; // TODO\n lms = false; // TODO\n dlarg_lo: number = 0;\n dlarg_hi: number = 0;\n period: number = 0;\t\t// current mode period bitmask\n scanaddr: number = 0; // Scan Address (via LMS)\n startaddr: number = 0;\t// Start of line Address\n pfbyte: number = 0;\t\t// playfield byte fetched\n ch: number = 0;\t\t\t\t// char read\n linesleft: number = 0; // # of lines left in mode\n yofs: number = 0;\t\t\t// yofs fine\n v: number = 0;\t\t\t\t\t// vertical scanline #\n h: number = 0;\t\t\t\t\t// horizontal color clock\n\n linebuf = new Uint8Array(48);\n dmaclock: number = 0;\n dmaidx: number = 0;\n output: number = 0;\n dramrefresh = false;\n vscroll = 0;\n\n constructor(readfn, nmifn) {\n this.read = readfn; // bus read function\n this.nmi = nmifn; // NMI function\n }\n reset() {\n this.regs.fill(0);\n this.regs[NMIEN] = 0x00;\n this.regs[NMIST] = 0x7f;\n this.regs[PENH] = 0x00;\n this.regs[PENV] = 0xff;\n this.setReg(DMACTL, 0x0);\n this.h = this.v = 0;\n this.startaddr = this.scanaddr = 0;\n this.dmaclock = 0;\n }\n saveState() {\n return safe_extend(0, {}, this);\n }\n loadState(s) {\n safe_extend(0, this, s);\n this.setReg(DMACTL, s.regs[DMACTL]);\n }\n static stateToLongString(state): string {\n let s = \"\";\n s += \"H: \" + lpad(state.h, 3) + \" V: \" + lpad(state.v, 3) + \"\\n\";\n s += \"DLIOp: \" + hex(state.dliop, 2) + \" Lines: \" + state.yofs + \"/\" + state.linesleft;\n s += \" DMA \" + (state.dma_enabled ? \"ON \" : \"off\") + \"\\n\";\n s += \"Addr: \" + hex(state.scanaddr, 4) + \"\\n\";\n s += dumpRAM(state.regs, 0, 16).replace('$00', 'Regs');\n return s;\n }\n setReg(a: number, v: number) {\n switch (a) {\n case WSYNC:\n this.regs[WSYNC] = 0xff;\n return; // this is readonly (we reset it)\n case NMIRES:\n this.regs[NMIST] = 0x1f;\n return; // this is readonly, don't mess with it\n }\n this.regs[a] = v;\n }\n readReg(a: number) {\n switch (a) {\n case NMIST:\n return this.regs[a];\n case VCOUNT:\n return this.v >> 1;\n default:\n return 0xff;\n }\n }\n processDLIEntry() {\n if (this.mode == 0) { // N Blank Lines\n this.linesleft = ((this.dliop >> 4) & 7) + 1;\n } else {\n this.linesleft = MODE_LINES[this.mode];\n this.period = MODE_PERIOD[this.mode];\n if (this.jmp) {\n this.regs[DLISTL] = this.dlarg_lo;\n this.regs[DLISTH] = this.dlarg_hi;\n this.mode = this.period = 0;\n // JVB (Jump and wait for Vertical Blank)\n if (this.dliop & 0x40) {\n this.linesleft = 1; //(248 - this.v) & 0xff; // TODO?\n this.dma_enabled = false;\n }\n } else if (this.lms) {\n this.scanaddr = this.dlarg_lo + (this.dlarg_hi << 8);\n //console.log('scanaddr', hex(this.scanaddr));\n }\n this.startaddr = this.scanaddr;\n }\n // horiz scroll\n let effwidth = this.regs[DMACTL] & 3;\n let hscroll = (this.dliop & 0x10) ? (this.regs[HSCROL] & 15) >> 1 : 0;\n if ((this.dliop & 0x10) && effwidth < 3) effwidth++;\n this.left = PF_LEFT[effwidth] + hscroll;\n this.right = PF_RIGHT[effwidth] + hscroll;\n // vertical scroll\n let vscrol = this.regs[VSCROL] & 0xf;\n if ((this.dliop & 0x20) ^ this.vscroll) {\n if (this.vscroll) {\n this.linesleft -= vscrol;\n } else {\n this.linesleft -= vscrol;\n this.yofs += vscrol;\n }\n this.vscroll ^= 0x20;\n }\n }\n\n nextLine() {\n if (this.linesleft > 0) {\n this.linesleft--;\n this.yofs++;\n if (this.mode >= 8 && this.linesleft) {\n this.scanaddr = this.startaddr; // reset line addr\n }\n }\n }\n\n triggerNMI(mask: number) {\n this.regs[NMIST] = mask | 0x1f;\n if (this.regs[NMIEN] & mask) {\n this.nmi();\n }\n }\n\n nextInsn(): number {\n let pc = this.regs[DLISTL] + (this.regs[DLISTH] << 8);\n let b = this.read(pc);\n //console.log('nextInsn', hex(pc), hex(b), this.v);\n pc = ((pc + 1) & 0x3ff) | (pc & ~0x3ff);\n this.regs[DLISTL] = pc & 0xff;\n this.regs[DLISTH] = pc >> 8;\n return b;\n }\n\n nextScreen(): number {\n let b = this.read(this.scanaddr);\n this.incScanAddr();\n return b;\n }\n incScanAddr() {\n this.scanaddr = ((this.scanaddr + 1) & 0xfff) | (this.scanaddr & ~0xfff);\n }\n\n dlDMAEnabled() { return this.regs[DMACTL] & 0b100000; }\n\n isVisibleScanline() {\n return this.v >= 8 && this.v < 248;\n }\n isPlayfieldDMAEnabled() {\n return this.dma_enabled && !this.linesleft;\n }\n isPlayerDMAEnabled() {\n return this.regs[DMACTL] & 0b1000;\n }\n isMissileDMAEnabled() {\n return this.regs[DMACTL] & 0b1100;\n }\n\n clockPulse(): boolean {\n let did_dma = this.regs[WSYNC] != 0;\n if (!this.isVisibleScanline()) {\n this.doVBlank();\n } else {\n switch (this.h) {\n case 0:\n if (this.isMissileDMAEnabled()) {\n this.doPlayerMissileDMA(3);\n did_dma = true;\n }\n break;\n case 1:\n if (this.isPlayfieldDMAEnabled()) {\n let op = this.nextInsn(); // get mode\n // TODO: too many booleans\n this.jmp = (op & ~0x40) == 0x01; // JMP insn?\n this.lms = (op & 0x40) != 0 && (op & 0xf) != 0; // LMS insn?\n this.mode = op & 0xf;\n this.dliop = op;\n this.yofs = 0;\n did_dma = true;\n }\n break;\n case 2: case 3: case 4: case 5:\n if (this.isPlayerDMAEnabled()) {\n this.doPlayerMissileDMA(this.h + 2);\n did_dma = true;\n }\n break;\n case 6:\n case 7:\n if (this.isPlayfieldDMAEnabled() && this.yofs == 0 && (this.jmp || this.lms)) {\n if (this.h == 6) this.dlarg_lo = this.nextInsn();\n if (this.h == 7) this.dlarg_hi = this.nextInsn();\n did_dma = true;\n }\n break;\n case 8:\n // TODO? is this at cycle 8?\n if (this.yofs == 0) {\n this.processDLIEntry();\n }\n if (this.dliop & 0x80) { // TODO: what if DLI disabled?\n if (this.linesleft == 1) {\n this.triggerNMI(0x80); // DLI interrupt\n }\n }\n break;\n case 9:\n break;\n case 111:\n if (this.dma_enabled) this.nextLine();\n ++this.v;\n break;\n }\n this.output = 0; // background color (TODO: only for blank lines)\n if (this.mode >= 2 && this.period) {\n let candma = this.h <= LAST_DMA_H;\n this.dmaclock <<= 1;\n if (this.dmaclock & (1 << this.period)) {\n this.dmaclock |= 1;\n }\n if (this.h == this.left) { this.dmaclock |= 1; this.dmaidx = 0; }\n if (this.h == this.right) { this.dmaclock &= ~1; this.dmaidx++; }\n if (this.dmaclock & 1) {\n if (this.mode < 8 && this.yofs == 0) { // only read chars on 1st line\n if (candma) {\n this.linebuf[this.dmaidx] = this.nextScreen(); // read char name\n } else {\n this.incScanAddr();\n }\n did_dma = candma;\n }\n this.dmaidx++;\n } else if (this.dmaclock & 8) {\n this.ch = this.linebuf[this.dmaidx - 4 / this.period]; // latch char\n if (candma) {\n this.readBitmapData(); // read bitmap\n } else {\n if (this.mode >= 8) this.incScanAddr();\n }\n did_dma = candma;\n }\n this.output = this.h >= this.left + 3 && this.h <= this.right + 2 ? 4 : 0;\n }\n }\n if (this.h < ANTIC_LEFT || this.h > ANTIC_RIGHT) this.output = 2;\n this.incHorizCounter();\n if (!did_dma && this.dramrefresh) {\n this.read(0); // to log a VRAM_READ event\n this.dramrefresh = false;\n did_dma = true;\n }\n return did_dma;\n }\n incHorizCounter() {\n switch (this.h) {\n case 25: case 25 + 4 * 1: case 25 + 4 * 2: case 25 + 4 * 3: case 25 + 4 * 4:\n case 25 + 4 * 5: case 25 + 4 * 6: case 25 + 4 * 7: case 25 + 4 * 8:\n this.dramrefresh = true;\n break;\n case 102:\n this.regs[WSYNC] = 0; // TODO: dram refresh delay to 106?\n break;\n case 113:\n this.h = 0;\n return\n }\n ++this.h;\n }\n doVBlank() {\n this.linesleft = this.mode = this.period = 0;\n if (this.h == 111) { this.v++; }\n if (this.v == 248 && this.h == 0) { this.triggerNMI(0x40); } // VBI\n if (this.v == 262 && this.h == 112) { this.v = 0; }\n if (this.v == 7 && this.h == 113) { \n this.dma_enabled = this.dlDMAEnabled() != 0;\n }\n this.output = 2; // blank\n }\n\n doPlayerMissileDMA(section: number) {\n let oneline = this.regs[DMACTL] & 0x10;\n let pmaddr = this.regs[PMBASE] << 8;\n if (oneline) {\n pmaddr &= 0xf800;\n pmaddr |= section << 8;\n pmaddr |= this.v & 0xff;\n } else {\n pmaddr &= 0xfc00;\n pmaddr |= section << 7;\n pmaddr |= this.v >> 1;\n }\n this.read(pmaddr);\n }\n\n readBitmapData() {\n const mode = this.mode;\n if (mode < 8) {\t// character mode\n let ch = this.ch;\n let y = this.yofs >> MODE_YPERIOD[this.mode];\n let addrofs = y & 7;\n let chbase = this.regs[CHBASE];\n // modes 6 & 7\n if ((mode & 0xe) == 6) { // or 7\n ch &= 0x3f;\n chbase &= 0xfe;\n } else {\n ch &= 0x7f;\n chbase &= 0xfc;\n }\n let addr = (ch << 3) + (chbase << 8);\n // modes 2 & 3\n if ((mode & 0xe) == 2) { // or 3\n let chactl = this.regs[CHACTL];\n let mode3lc = mode == 3 && (ch & 0x60) == 0x60;\n if (chactl & 4)\n this.pfbyte = this.read(addr + (addrofs ^ 7)); // mirror\n else\n this.pfbyte = this.read(addr + addrofs);\n if (mode3lc && y < 2) { this.pfbyte = 0; }\n if (!mode3lc && y > 7) { this.pfbyte = 0; }\n if (this.ch & 0x80) {\n if (chactl & 1)\n this.pfbyte = 0x0; // blank\n if (chactl & 2)\n this.pfbyte ^= 0xff; // invert\n }\n } else {\n this.pfbyte = this.read(addr + addrofs);\n }\n } else {\t// map mode\n this.pfbyte = this.nextScreen();\n }\n }\n\n shiftout() {\n if (this.output == 4) { // visible pixel?\n switch (this.mode) {\n case 2: case 3:\n case 15:\n {\n let v = (this.pfbyte >> 7) & 1;\n this.pfbyte <<= 1;\n return v ? 8 : 6;\n }\n case 6: case 7:\n {\n let v = (this.pfbyte >> 7) & 1;\n this.pfbyte <<= 1;\n return v ? (this.ch >> 6) + 4 : 0;\n }\n case 9: case 11: case 12:\n {\n let v = (this.pfbyte >> 7) & 1;\n this.pfbyte <<= 1;\n return v ? 4 : 0;\n }\n case 4: case 5:\n case 8: case 10:\n case 13: case 14:\n {\n let v = (this.pfbyte >> 6) & 3;\n this.pfbyte <<= 2;\n return [0, 4, 5, 6][v]; // TODO: 5th color\n }\n }\n }\n return this.output;\n }\n\n}\n", "\n// GTIA\n// https://user.xmission.com/~trevin/atari/gtia_regs.html\n// https://user.xmission.com/~trevin/atari/gtia_pinout.html\n\nimport { dumpRAM, gtia_ntsc_to_rgb } from \"../../common/emu\";\nimport { hex, lpad, safe_extend } from \"../../common/util\";\n\n\n// write regs\nconst HPOSP0 = 0x0;\nconst HPOSM0 = 0x4;\nconst SIZEP0 = 0x8;\nconst SIZEM = 0x0c;\nconst GRAFP0 = 0x0d;\nconst GRAFM = 0x11;\nconst COLPM0 = 0x12;\nconst COLPF0 = 0x16;\nconst COLPF1 = 0x17;\nconst COLPF2 = 0x18;\nconst COLPF3 = 0x19;\nconst COLBK = 0x1a;\nconst PRIOR = 0x1b;\nconst VDELAY = 0x1c; // TODO\nconst GRACTL = 0x1d;\nconst HITCLR = 0x1e;\nconst CONSPK = 0x1f;\n// read regs\nconst M0PF = 0x0;\nconst P0PF = 0x4;\nconst M0PL = 0x8;\nconst P0PL = 0xc;\nexport const TRIG0 = 0x10;\nexport const CONSOL = 0x1f;\n\nconst HOFFSET = -9; // bias to account for antic->gtia delay\n\nconst PRIOR_TABLE : number[] = [\n 0,1,2,3, 7,7,7,7, 8,8,8,8, 4,5,6,7, // 0001 - 0\n 0,1,2,3, 7,7,7,7, 8,8,8,8, 4,5,6,7, // 0001\n 0,1,6,7, 5,5,5,5, 8,8,8,8, 2,3,4,5, // 0010 - 2\n 0,1,6,7, 5,5,5,5, 8,8,8,8, 2,3,4,5, // 0010\n 4,5,6,7, 3,3,3,3, 8,8,8,8, 0,1,2,3, // 0100 - 4\n 4,5,6,7, 3,3,3,3, 8,8,8,8, 0,1,2,3, // 0100\n 4,5,6,7, 3,3,3,3, 8,8,8,8, 0,1,2,3, // 0100\n 4,5,6,7, 3,3,3,3, 8,8,8,8, 0,1,2,3, // 0100\n 2,3,4,5, 7,7,7,7, 8,8,8,8, 0,1,6,7, // 1000 - 8\n 2,3,4,5, 7,7,7,7, 8,8,8,8, 0,1,6,7, // 1000\n 2,3,4,5, 7,7,7,7, 8,8,8,8, 0,1,6,7, // 1000\n 2,3,4,5, 7,7,7,7, 8,8,8,8, 0,1,6,7, // 1000\n 2,3,4,5, 7,7,7,7, 8,8,8,8, 0,1,6,7, // 1000\n 2,3,4,5, 7,7,7,7, 8,8,8,8, 0,1,6,7, // 1000\n 2,3,4,5, 7,7,7,7, 8,8,8,8, 0,1,6,7, // 1000\n 2,3,4,5, 7,7,7,7, 8,8,8,8, 0,1,6,7, // 1000\n];\n\nconst MODE_9_LOOKUP = [\n COLPM0+0, COLPM0+1, COLPM0+2, COLPM0+3,\n COLPF0+0, COLPF0+1, COLPF0+2, COLPF0+3,\n COLBK, COLBK, COLBK, COLBK,\n COLPF0+0, COLPF0+1, COLPF0+2, COLPF0+3,\n]\n\nexport class GTIA {\n regs = new Uint8Array(0x20);\n readregs = new Uint8Array(0x20);\n shiftregs = new Uint32Array(8);\n priortab = new Uint8Array(12);\n\n count = 0;\n an = 0;\n rgb = 0;\n pmcol = 0;\n gtiacol = 0;\n gtiacol2 = 0;\n hbias = HOFFSET;\n\n reset() {\n this.regs.fill(0);\n this.readregs.fill(0); // TODO?\n this.readregs[0x14] = 0xf; // NTSC\n this.count = 0;\n }\n saveState() {\n return safe_extend(0, {}, this);\n }\n loadState(s) {\n safe_extend(0, this, s);\n }\n setReg(a: number, v: number) {\n switch (a) {\n case COLPM0: case COLPM0+1: case COLPM0+2: case COLPM0+3:\n case COLPF0: case COLPF0+1: case COLPF0+2: case COLPF0+3:\n case COLBK:\n v &= 0xfe; // bit 0 unused in color regs\n break;\n case HITCLR:\n this.readregs.fill(0, 0, 16);\n return;\n }\n this.regs[a] = v;\n }\n readReg(a: number) {\n switch (a) {\n case CONSOL:\n return this.readregs[a] & ~this.regs[CONSPK];\n }\n return this.readregs[a];\n }\n sync() {\n this.count = 0;\n }\n setBias(b: number) {\n this.hbias = HOFFSET + b;\n }\n updateGfx(h: number, data: number) {\n switch (h) {\n case 0:\n if (this.regs[GRACTL] & 1) { this.regs[GRAFM] = data; }\n break;\n case 2: case 3: case 4: case 5:\n if (this.regs[GRACTL] & 2) { this.regs[GRAFP0 - 2 + h] = data; }\n break;\n }\n }\n getPlayfieldColor(): number {\n // which GTIA mode?\n switch (this.regs[PRIOR] >> 6) {\n // normal mode\n case 0:\n switch (this.an) {\n case 0:\n return COLBK;\n case 4: case 5: case 6: case 7:\n return COLPF0 + this.an - 4;\n case 8:\n // combine PF2 hue and PF1 luminance\n return (this.regs[COLPF2] & 0xf0) | (this.regs[COLPF1] & 0x0f) | 0x100;\n }\n break;\n // mode 9 -- 16 luminances\n case 1:\n return (this.regs[COLBK] & 0xf0) | (this.gtiacol & 0xf) | 0x100;\n // mode 10 -- 9 colors from registers\n case 2:\n return MODE_9_LOOKUP[this.gtiacol];\n // mode 11 -- 16 hues\n case 3:\n return (this.regs[COLBK] & 0xf) | (this.gtiacol << 4) | 0x100;\n }\n return 0x100; // black\n }\n anySpriteActive() {\n return this.shiftregs[0] | this.shiftregs[1] | this.shiftregs[2]\n | this.shiftregs[3] | this.shiftregs[4] | this.shiftregs[5]\n | this.shiftregs[6] | this.shiftregs[7];\n }\n processPlayerMissile() {\n // no p/m gfx, no collisions in blank area, but shift and trigger anyway\n if (this.an == 2 || !this.anySpriteActive()) {\n for (let i = 0; i < 8; i++) {\n this.shiftObject(i);\n }\n this.pmcol = -1;\n return;\n }\n // TODO: multiple color player enable\n // TODO: gtia, hi-res mode collisions\n // compute gfx and collisions for players/missiles\n let priobias = (this.regs[PRIOR] & 15) << 4; // TODO\n let topprio = PRIOR_TABLE[(this.an & 7) + 8 + priobias];\n let pfset = this.an - 4; // TODO?\n let topobj = -1;\n let ppmask = 0;\n let ppcount = 0;\n // players\n for (let i = 0; i < 4; i++) {\n let bit = this.shiftObject(i);\n if (bit) {\n if (pfset >= 0) { // TODO: hires and GTIA modes\n this.readregs[P0PF + i] |= 1 << pfset;\n }\n ppmask |= 1 << i;\n ppcount++;\n let prio = PRIOR_TABLE[i + priobias];\n if (prio < topprio) {\n topobj = i;\n topprio = prio;\n }\n }\n }\n // missiles\n for (let i = 0; i < 4; i++) {\n let bit = this.shiftObject(i + 4);\n if (bit) {\n if (pfset >= 0) {\n this.readregs[M0PF + i] |= 1 << pfset;\n }\n this.readregs[M0PL + i] |= ppmask;\n let prio = PRIOR_TABLE[i + priobias];\n if (prio < topprio) {\n topobj = i + 4;\n topprio = prio;\n }\n }\n }\n // set player-player collision flags\n if (ppcount > 1) {\n this.readregs[P0PL + 0] |= ppmask & ~1;\n this.readregs[P0PL + 1] |= ppmask & ~2;\n this.readregs[P0PL + 2] |= ppmask & ~4;\n this.readregs[P0PL + 3] |= ppmask & ~8;\n }\n this.pmcol = topobj >= 0 ? this.getObjectColor(topobj) : -1;\n }\n shiftObject(i: number) {\n let bit = (this.shiftregs[i] & 0x80000000) != 0;\n this.shiftregs[i] <<= 1;\n if (this.regs[HPOSP0 + i] + this.hbias == this.count) {\n this.triggerObject(i);\n }\n return bit;\n }\n getObjectColor(i: number) {\n if ((this.regs[PRIOR] & 0x10) && i >= 4) {\n return this.regs[COLPF3];\n } else {\n return this.regs[COLPM0 + (i & 3)];\n }\n }\n triggerObject(i: number) {\n let size, data;\n if (i < 4) {\n size = this.regs[SIZEP0 + i] & 3;\n data = this.regs[GRAFP0 + i];\n } else {\n let s = (i - 4) << 1;\n size = (this.regs[SIZEM] >> s) & 3;\n data = ((this.regs[GRAFM] >> s) & 3) << 6;\n }\n if (size & 1) data = expandBits(data); else data <<= 8;\n if (size == 3) data = expandBits(data); else data <<= 16;\n this.shiftregs[i] = data;\n }\n\n clockPulse1(): void {\n this.processPlayerMissile();\n this.clockPulse2();\n this.count++;\n }\n\n clockPulse2(): void {\n var col: number;\n if (this.pmcol >= 0) {\n col = this.pmcol;\n } else {\n let pf = this.getPlayfieldColor();\n col = pf & 0x100 ? pf & 0xff : this.regs[pf];\n }\n this.rgb = COLORS_RGBA[col];\n // TODO: hires modes return 8, so other modes wont work\n this.gtiacol2 = (this.gtiacol2 << 1) | (this.an >> 3);\n }\n\n clockPulse4() {\n // latch GTIA buffer\n this.gtiacol = this.gtiacol2 & 15;\n }\n\n static stateToLongString(state): string {\n let s = ''\n s += `X: ${lpad(state.count, 3)} ANTIC: ${hex(state.an, 1)} PM: ${hex(state.pmcol, 3)}\\n`;\n s += \"Write Registers:\\n\";\n s += dumpRAM(state.regs, 0, 32);\n s += \"Read Registers:\\n\";\n s += dumpRAM(state.readregs, 0, 32);\n return s;\n }\n}\n\nfunction expandBits(x: number): number {\n x = (x | (x << 8)) & 0x00FF00FF;\n x = (x | (x << 4)) & 0x0F0F0F0F;\n x = (x | (x << 2)) & 0x33333333;\n x = (x | (x << 1)) & 0x55555555;\n return x | (x << 1);\n}\n\nvar COLORS_RGBA = new Uint32Array(256);\nfor (var i = 0; i < 256; i++) {\n COLORS_RGBA[i] = gtia_ntsc_to_rgb(i);\n}\n\n", "/*\n * pokey.c - POKEY sound chip emulation\n *\n * Copyright (C) 1995-1998 David Firth\n * Copyright (C) 1998-2008 Atari800 development team (see DOC/CREDITS)\n *\n * This file is part of the Atari800 emulator project which emulates\n * the Atari 400, 800, 800XL, 130XE, and 5200 8-bit computers.\n *\n * Atari800 is free software; you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation; either version 2 of the License, or\n * (at your option) any later version.\n *\n * Atari800 is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with Atari800; if not, write to the Free Software\n * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n*/\n\nimport { dumpRAM } from \"../../common/emu\"\nimport { hex, lpad, safe_extend } from \"../../common/util\"\n\nconst AUDF1 = 0x00\nconst AUDC1 = 0x01\nconst AUDF2 = 0x02\nconst AUDC2 = 0x03\nconst AUDF3 = 0x04\nconst AUDC3 = 0x05\nconst AUDF4 = 0x06\nconst AUDC4 = 0x07\nconst AUDCTL = 0x08\nconst STIMER = 0x09\nconst SKRES = 0x0a\nconst POTGO = 0x0b\nconst SEROUT = 0x0d\nconst IRQEN = 0x0e\nconst SKCTL = 0x0f\n\nconst POT0 = 0x00\nconst POT1 = 0x01\nconst POT2 = 0x02\nconst POT3 = 0x03\nconst POT4 = 0x04\nconst POT5 = 0x05\nconst POT6 = 0x06\nconst POT7 = 0x07\nconst ALLPOT = 0x08\nconst KBCODE = 0x09\nconst RANDOM = 0x0a\nconst SERIN = 0x0d\nconst IRQST = 0x0e\nconst SKSTAT = 0x0f\n\n/* definitions for AUDCx (D201, D203, D205, D207) */\nconst NOTPOLY5 = 0x80 /* selects POLY5 or direct CLOCK */\nconst POLY4 = 0x40 /* selects POLY4 or POLY17 */\nconst PURETONE = 0x20 /* selects POLY4/17 or PURE tone */\nconst VOL_ONLY = 0x10 /* selects VOLUME OUTPUT ONLY */\nconst VOLUME_MASK = 0x0f /* volume mask */\n\n/* definitions for AUDCTL (D208) */\nconst POLY9 = 0x80 /* selects POLY9 or POLY17 */\nconst CH1_179 = 0x40 /* selects 1.78979 MHz for Ch 1 */\nconst CH3_179 = 0x20 /* selects 1.78979 MHz for Ch 3 */\nconst CH1_CH2 = 0x10 /* clocks channel 1 w/channel 2 */\nconst CH3_CH4 = 0x08 /* clocks channel 3 w/channel 4 */\nconst CH1_FILTER = 0x04 /* selects channel 1 high pass filter */\nconst CH2_FILTER = 0x02 /* selects channel 2 high pass filter */\nconst CLOCK_15 = 0x01 /* selects 15.6999kHz or 63.9210kHz */\n\n/* for accuracy, the 64kHz and 15kHz clocks are exact divisions of\n the 1.79MHz clock */\nconst DIV_64 = 28 /* divisor for 1.79MHz clock to 64 kHz */\nconst DIV_15 = 114 /* divisor for 1.79MHz clock to 15 kHz */\n\n/* the size (in entries) of the 4 polynomial tables */\nconst POLY4_SIZE = 0x000f\nconst POLY5_SIZE = 0x001f\nconst POLY9_SIZE = 0x01ff\nconst POLY17_SIZE = 0x0001ffff\n\nconst CHAN1 = 0\nconst CHAN2 = 1\nconst CHAN3 = 2\nconst CHAN4 = 3\n\nconst ANTIC_LINE_C = 114\n\n/* Some defines about the serial I/O timing. Currently fixed! */\nconst SIO_XMTDONE_INTERVAL = 15\nconst SIO_SERIN_INTERVAL = 8\nconst SIO_SEROUT_INTERVAL = 8\nconst SIO_ACK_INTERVAL = 36\n\nvar poly9: Uint8Array;\nvar poly17: Uint8Array;\n\nfunction initPolyTables() {\n poly9 = new Uint8Array(511);\n poly17 = new Uint8Array(16385);\n /* initialise poly9_lookup */\n let reg = 0x1ff;\n for (let i = 0; i < 511; i++) {\n reg = ((((reg >> 5) ^ reg) & 1) << 8) + (reg >> 1);\n poly9[i] = reg;\n }\n /* initialise poly17_lookup */\n reg = 0x1ffff;\n for (let i = 0; i < 16385; i++) {\n reg = ((((reg >> 5) ^ reg) & 0xff) << 9) + (reg >> 8);\n poly17[i] = (reg >> 1);\n }\n}\n\nexport class POKEY {\n regs = new Uint8Array(16);\n readregs = new Uint8Array(16);\n divnirq = new Uint32Array(4);\n divnmax = new Uint32Array(4);\n pot_inputs = new Uint8Array(8);\n basemult = 0;\n pot_scanline = 0;\n random_scanline_counter = 0;\n kbcode = 0;\n DELAYED_SERIN_IRQ = 0;\n DELAYED_SEROUT_IRQ = 0;\n DELAYED_XMTDONE_IRQ = 0;\n\n constructor(\n public irq: () => void,\n public antic_xpos: () => number,\n ) {\n this.init();\n }\n\n saveState() {\n return safe_extend(0, {}, this);\n }\n loadState(s) {\n safe_extend(0, this, s);\n }\n\n init() {\n /* Initialise Serial Port Interrupts */\n //DELAYED_SERIN_IRQ = 0;\n //DELAYED_SEROUT_IRQ = 0;\n //DELAYED_XMTDONE_IRQ = 0;\n this.readregs.fill(0xff);\n this.readregs[SKSTAT] = 0xef;\n //SERIN = 0x00;\t/* or 0xff ? */\n //IRQEN = 0x00;\n //SKCTL = 0x00;\n this.basemult = DIV_64;\n this.pot_inputs.fill(128);\n initPolyTables();\n }\n\n\n read(addr: number): number {\n let byte = this.readregs[addr];\n addr &= 0xf;\n switch (addr) {\n case 0: case 1: case 2: case 3:\n case 4: case 5: case 6: case 7:\n byte = this.pot_inputs[addr];\n return (byte < this.pot_scanline) ? byte : this.pot_scanline;\n case ALLPOT:\n for (let i = 0; i < 8; i++) {\n if (this.pot_inputs[i] <= this.pot_scanline)\n byte &= ~(1 << i);\t\t// reset bit if pot value known\n }\n break;\n case KBCODE:\n return this.kbcode;\n case SKSTAT:\n byte = SKSTAT + (this.CASSETTE_IOLineStatus() << 4);\n break;\n case RANDOM:\n if ((this.regs[SKCTL] & 0x03) != 0) {\n let i = this.random_scanline_counter + this.antic_xpos();\n if (this.regs[AUDCTL] & POLY9)\n byte = poly9[i % POLY9_SIZE];\n else {\n i %= POLY17_SIZE;\n let ptr = i >> 3;\n i &= 7;\n byte = (poly17[ptr] >> i) + (poly17[ptr + 1] << (8 - i));\n }\n }\n break;\n }\n return byte & 0xff;\n }\n\n write(addr: number, byte: number): void {\n addr &= 0x0f;\n this.regs[addr] = byte;\n switch (addr) {\n case AUDCTL:\n /* determine the base multiplier for the 'div by n' calculations */\n if (byte & CLOCK_15)\n this.basemult = DIV_15;\n else\n this.basemult = DIV_64;\n this.update_counter((1 << CHAN1) | (1 << CHAN2) | (1 << CHAN3) | (1 << CHAN4));\n break;\n case AUDF1:\n this.update_counter((this.regs[AUDCTL] & CH1_CH2) ? ((1 << CHAN2) | (1 << CHAN1)) : (1 << CHAN1));\n break;\n case AUDF2:\n this.update_counter(1 << CHAN2);\n break;\n case AUDF3:\n this.update_counter((this.regs[AUDCTL] & CH3_CH4) ? ((1 << CHAN4) | (1 << CHAN3)) : (1 << CHAN3));\n break;\n case AUDF4:\n this.update_counter(1 << CHAN4);\n break;\n case IRQEN:\n this.readregs[IRQST] |= ~byte & 0xf7;\t/* Reset disabled IRQs except XMTDONE */\n let mask = ~this.readregs[IRQST] & this.regs[IRQEN];\n if (mask) {\n this.generateIRQ(this.readregs[IRQST]);\n }\n break;\n case SKRES:\n this.readregs[SKSTAT] |= 0xe0;\n break;\n case POTGO:\n if (!(this.regs[SKCTL] & 4))\n this.pot_scanline = 0;\t/* slow pot mode */\n break;\n case SEROUT:\n if ((this.regs[SKCTL] & 0x70) == 0x20 && this.siocheck()) {\n this.SIO_PutByte(byte);\n }\n // check if cassette 2-tone mode has been enabled \n if ((this.regs[SKCTL] & 0x08) == 0x00) {\n // intelligent device\n this.DELAYED_SEROUT_IRQ = SIO_SEROUT_INTERVAL;\n this.readregs[IRQST] |= 0x08;\n this.DELAYED_XMTDONE_IRQ = SIO_XMTDONE_INTERVAL;\n }\n else {\n // cassette \n // some savers patch the cassette baud rate, so we evaluate it here \n // scanlines per second*10 bit*audiofrequency/(1.79 MHz/2) \n this.DELAYED_SEROUT_IRQ = 312 * 50 * 10 * (this.regs[AUDF3] + this.regs[AUDF4] * 0x100) / 895000;\n // safety check \n if (this.DELAYED_SEROUT_IRQ >= 3) {\n this.readregs[IRQST] |= 0x08;\n this.DELAYED_XMTDONE_IRQ = 2 * this.DELAYED_SEROUT_IRQ - 2;\n }\n else {\n this.DELAYED_SEROUT_IRQ = 0;\n this.DELAYED_XMTDONE_IRQ = 0;\n }\n };\n break;\n case STIMER:\n this.divnirq[CHAN1] = this.divnmax[CHAN1];\n this.divnirq[CHAN2] = this.divnmax[CHAN2];\n this.divnirq[CHAN3] = this.divnmax[CHAN3];\n this.divnirq[CHAN4] = this.divnmax[CHAN4];\n //POKEYSND_Update(STIMER, byte, 0, SOUND_GAIN);\n break;\n case SKCTL:\n //VOICEBOX_SKCTLPutByte(byte);\n //POKEYSND_Update(SKCTL, byte, 0, SOUND_GAIN);\n if (byte & 4)\n this.pot_scanline = 228;\t/* fast pot mode - return results immediately */\n if ((byte & 0x03) == 0) {\n /* POKEY reset. */\n /* Stop serial IO. */\n this.DELAYED_SERIN_IRQ = 0;\n this.DELAYED_SEROUT_IRQ = 0;\n this.DELAYED_XMTDONE_IRQ = 0;\n // TODO: CASSETTE_ResetPOKEY();\n /* TODO other registers should also be reset. */\n }\n break;\n }\n this.snd_update(addr);\n //POKEYSND_Update(AUDC1, byte, 0, SOUND_GAIN);\n }\n\n /*****************************************************************************/\n /* Module: Update_Counter() */\n /* Purpose: To process the latest control values stored in the AUDF, AUDC, */\n /* and AUDCTL registers. It pre-calculates as much information as */\n /* possible for better performance. This routine has been added */\n /* here again as I need the precise frequency for the pokey timers */\n /* again. The pokey emulation is therefore somewhat sub-optimal */\n /* since the actual pokey emulation should grab the frequency values */\n /* directly from here instead of calculating them again. */\n /* */\n /* Author: Ron Fries,Thomas Richter */\n /* Date: March 27, 1998 */\n /* */\n /* Inputs: chan_mask: Channel mask, one bit per channel. */\n /* The channels that need to be updated */\n /* */\n /* Outputs: Adjusts local globals - no return value */\n /* */\n /*****************************************************************************/\n\n update_counter(chan_mask: number): void {\n\n /************************************************************/\n /* As defined in the manual, the exact Div_n_cnt values are */\n /* different depending on the frequency and resolution: */\n /* 64 kHz or 15 kHz - AUDF + 1 */\n /* 1 MHz, 8-bit - AUDF + 4 */\n /* 1 MHz, 16-bit - AUDF[CHAN1]+256*AUDF[CHAN2] + 7 */\n /************************************************************/\n\n /* only reset the channels that have changed */\n\n if (chan_mask & (1 << CHAN1)) {\n /* process channel 1 frequency */\n if (this.regs[AUDCTL] & CH1_179)\n this.divnmax[CHAN1] = this.regs[AUDF1 + CHAN1] + 4;\n else\n this.divnmax[CHAN1] = (this.regs[AUDF1 + CHAN1] + 1) * this.basemult;\n if (this.divnmax[CHAN1] < ANTIC_LINE_C)\n this.divnmax[CHAN1] = ANTIC_LINE_C;\n }\n\n if (chan_mask & (1 << CHAN2)) {\n /* process channel 2 frequency */\n if (this.regs[AUDCTL] & CH1_CH2) {\n if (this.regs[AUDCTL] & CH1_179)\n this.divnmax[CHAN2] = this.regs[AUDF1 + CHAN2] * 256 + this.regs[AUDF1 + CHAN1] + 7;\n else\n this.divnmax[CHAN2] = (this.regs[AUDF1 + CHAN2] * 256 + this.regs[AUDF1 + CHAN1] + 1) * this.basemult;\n }\n else\n this.divnmax[CHAN2] = (this.regs[AUDF1 + CHAN2] + 1) * this.basemult;\n if (this.divnmax[CHAN2] < ANTIC_LINE_C)\n this.divnmax[CHAN2] = ANTIC_LINE_C;\n }\n\n if (chan_mask & (1 << CHAN4)) {\n /* process channel 4 frequency */\n if (this.regs[AUDCTL] & CH3_CH4) {\n if (this.regs[AUDCTL] & CH3_179)\n this.divnmax[CHAN4] = this.regs[AUDF1 + CHAN4] * 256 + this.regs[AUDF1 + CHAN3] + 7;\n else\n this.divnmax[CHAN4] = (this.regs[AUDF1 + CHAN4] * 256 + this.regs[AUDF1 + CHAN3] + 1) * this.basemult;\n }\n else\n this.divnmax[CHAN4] = (this.regs[AUDF1 + CHAN4] + 1) * this.basemult;\n if (this.divnmax[CHAN4] < ANTIC_LINE_C)\n this.divnmax[CHAN4] = ANTIC_LINE_C;\n }\n\n //console.log(chan_mask, this.divnmax);\n }\n\n snd_update(addr: number) {\n\n }\n\n advanceScanline() {\n /***************************************************************************\n ** Generate POKEY Timer IRQs if required **\n ** called on a per-scanline basis, not very precise, but good enough **\n ** for most applications **\n ***************************************************************************/\n\n\n /* on nonpatched i/o-operation, enable the cassette timing */\n /*\n if (!ESC_enable_sio_patch) {\n if (CASSETTE_AddScanLine())\n DELAYED_SERIN_IRQ = 1;\n }\n */\n\n if ((this.regs[SKCTL] & 0x03) == 0)\n /* Don't process timers when POKEY is in reset mode. */\n return;\n\n if (this.pot_scanline < 228)\n this.pot_scanline++;\n\n this.random_scanline_counter += ANTIC_LINE_C;\n this.random_scanline_counter %= (this.regs[AUDCTL] & POLY9) ? POLY9_SIZE : POLY17_SIZE;\n\n if (this.DELAYED_SERIN_IRQ > 0) {\n if (--this.DELAYED_SERIN_IRQ == 0) {\n // Load a byte to SERIN - even when the IRQ is disabled. \n this.readregs[SERIN] = this.SIO_GetByte();\n this.generateIRQ(0x20);\n }\n }\n\n if (this.DELAYED_SEROUT_IRQ > 0) {\n if (--this.DELAYED_SEROUT_IRQ == 0) {\n this.generateIRQ(0x10);\n }\n }\n\n if (this.DELAYED_XMTDONE_IRQ > 0)\n if (--this.DELAYED_XMTDONE_IRQ == 0) {\n this.generateIRQ(0x08);\n }\n\n this.advanceIRQTimer(CHAN1, 0x1);\n this.advanceIRQTimer(CHAN2, 0x2);\n this.advanceIRQTimer(CHAN4, 0x4);\n }\n\n advanceIRQTimer(chan: number, mask: number) {\n if ((this.divnirq[chan] -= ANTIC_LINE_C) < 0) {\n this.divnirq[chan] += this.divnmax[chan];\n this.generateIRQ(mask);\n //console.log('irq', chan, this.divnirq[chan], this.divnmax[chan])\n }\n }\n\n generateIRQ(mask: number) {\n if (this.regs[IRQEN] & mask) {\n this.irq();\n this.readregs[IRQST] &= ~mask;\n }\n }\n\n static stateToLongString(state): string {\n let s = ''\n s += \"Write Registers:\\n\";\n s += dumpRAM(state.regs, 0, 16);\n s += \"Read Registers:\\n\";\n s += dumpRAM(state.readregs, 0, 16);\n return s;\n }\n\n CASSETTE_IOLineStatus() {\n return 0;\n }\n\n siocheck() {\n return (((this.regs[AUDF1 + CHAN3] == 0x28 || this.regs[AUDF1 + CHAN3] == 0x10\n || this.regs[AUDF1 + CHAN3] == 0x08 || this.regs[AUDF1 + CHAN3] == 0x0a)\n && this.regs[AUDF1 + CHAN4] == 0x00) // intelligent peripherals speeds\n || (this.regs[SKCTL] & 0x78) == 0x28) // cassette save mode\n && (this.regs[AUDCTL] & 0x28) == 0x28;\n }\n SIO_PutByte(byte: number) {\n // TODO\n console.log(\"SIO put byte\", byte);\n }\n SIO_GetByte() {\n return 0; // TODO\n }\n\n}\n\n\n//const SOUND_GAIN 4\n/*\nvoid Frame(void)\n{\n random_scanline_counter %= (this.regs[AUDCTL] & POLY9) ? POLY9_SIZE : POLY17_SIZE;\n}\n*/\n\n\n\n", "import { newPOKEYAudio, TssChannelAdapter } from \"../common/audio\";\nimport { Machine } from \"../common/baseplatform\";\nimport { MOS6502 } from \"../common/cpu/MOS6502\";\nimport { AcceptsKeyInput, AcceptsPaddleInput, AcceptsROM, BasicScanlineMachine, FrameBased, Probeable, TrapCondition, VideoSource } from \"../common/devices\";\nimport { KeyFlags, Keys, makeKeycodeMap, newAddressDecoder, newKeyboardHandler } from \"../common/emu\";\nimport { hex } from \"../common/util\";\nimport { BaseWASIMachine } from \"../common/wasmplatform\";\nimport { ANTIC, MODE_SHIFT } from \"./chips/antic\";\nimport { CONSOL, GTIA, TRIG0 } from \"./chips/gtia\";\nimport { POKEY } from \"./chips/pokey\";\n\nconst ATARI8_KEYMATRIX_INTL_NOSHIFT = [\n Keys.VK_L, Keys.VK_J, Keys.VK_SEMICOLON, Keys.VK_F1, Keys.VK_F2, Keys.VK_K, Keys.VK_BACK_SLASH, Keys.VK_TILDE,\n Keys.VK_O, null, Keys.VK_P, Keys.VK_U, Keys.VK_ENTER, Keys.VK_I, Keys.VK_MINUS2, Keys.VK_EQUALS2,\n Keys.VK_V, Keys.VK_F8, Keys.VK_C, Keys.VK_F3, Keys.VK_F4, Keys.VK_B, Keys.VK_X, Keys.VK_Z,\n Keys.VK_4, null, Keys.VK_3, Keys.VK_6, Keys.VK_ESCAPE, Keys.VK_5, Keys.VK_2, Keys.VK_1,\n Keys.VK_COMMA, Keys.VK_SPACE, Keys.VK_PERIOD, Keys.VK_N, null, Keys.VK_M, Keys.VK_SLASH, null/*invert*/,\n Keys.VK_R, null, Keys.VK_E, Keys.VK_Y, Keys.VK_TAB, Keys.VK_T, Keys.VK_W, Keys.VK_Q,\n Keys.VK_9, null, Keys.VK_0, Keys.VK_7, Keys.VK_BACK_SPACE, Keys.VK_8, null, null,\n Keys.VK_F, Keys.VK_H, Keys.VK_D, null, Keys.VK_CAPS_LOCK, Keys.VK_G, Keys.VK_S, Keys.VK_A,\n];\n\n//TODO\nvar ATARI8_KEYCODE_MAP = makeKeycodeMap([\n [Keys.UP, 0, 0x1],\n [Keys.DOWN, 0, 0x2],\n [Keys.LEFT, 0, 0x4],\n [Keys.RIGHT, 0, 0x8],\n [Keys.VK_SHIFT, 2, 0x1],\n /*\n [Keys.P2_UP, 0, 0x10],\n [Keys.P2_DOWN, 0, 0x20],\n [Keys.P2_LEFT, 0, 0x40],\n [Keys.P2_RIGHT, 0, 0x80],\n [Keys.P2_A, 3, 0x1],\n */\n [Keys.START, 3, 0x1], // START\n [Keys.SELECT, 3, 0x2], // SELECT\n [Keys.OPTION, 3, 0x4], // OPTION\n]);\n\n\nexport class Atari800 extends BasicScanlineMachine {\n\n // http://www.ataripreservation.org/websites/freddy.offenga/megazine/ISSUE5-PALNTSC.html\n cpuFrequency = 1789773;\n numTotalScanlines = 262;\n cpuCyclesPerLine = 114;\n canvasWidth = 336;\n numVisibleScanlines = 224;\n aspectRatio = this.canvasWidth / this.numVisibleScanlines * 0.857;\n firstVisibleScanline = 16;\n firstVisibleClock = (44 - 6) * 2; // ... to 215 * 2\n defaultROMSize = 0x8000;\n overscan = true;\n audioOversample = 4;\n sampleRate = this.numTotalScanlines * 60 * this.audioOversample;\n\n cpu: MOS6502;\n ram: Uint8Array;\n bios: Uint8Array;\n bus;\n audio_pokey;\n audioadapter;\n antic: ANTIC;\n gtia: GTIA;\n irq_pokey: POKEY;\n inputs = new Uint8Array(4);\n linergb = new Uint32Array(this.canvasWidth);\n lastdmabyte = 0;\n keycode = 0;\n cart_80 = false;\n cart_a0 = false;\n xexdata = null;\n // TODO: save/load vars\n\n constructor() {\n super();\n this.cpu = new MOS6502();\n this.ram = new Uint8Array(0x10000);\n this.bios = new Uint8Array(0x2800);\n this.bus = this.newBus();\n this.connectCPUMemoryBus(this.bus);\n // create support chips\n this.antic = new ANTIC(this.readDMA.bind(this), this.antic_nmi.bind(this));\n this.gtia = new GTIA();\n this.irq_pokey = new POKEY(this.pokey_irq.bind(this), () => this.antic.h);\n this.audio_pokey = newPOKEYAudio(1);\n this.audioadapter = new TssChannelAdapter(this.audio_pokey.pokey1, this.audioOversample, this.sampleRate);\n this.handler = newKeyboardHandler(\n this.inputs, ATARI8_KEYCODE_MAP, this.getKeyboardFunction(), true);\n }\n\n newBus() {\n return {\n // TODO: https://github.com/dmlloyd/atari800/blob/master/DOC/cart.txt\n read: newAddressDecoder([\n [0x0000, 0x7fff, 0xffff, (a) => { return this.ram[a]; }],\n [0x8000, 0x9fff, 0xffff, (a) => { return this.cart_80 ? this.rom[a - 0x8000] : this.ram[a]; }],\n [0xa000, 0xbfff, 0xffff, (a) => { return this.cart_a0 ? this.rom[a - 0x8000] : this.ram[a]; }],\n [0xd000, 0xd0ff, 0x1f, (a) => { return this.gtia.readReg(a); }],\n [0xd200, 0xd2ff, 0xf, (a) => { return this.readPokey(a); }],\n [0xd300, 0xd3ff, 0xf, (a) => { return this.readPIA(a); }],\n [0xd400, 0xd4ff, 0xf, (a) => { return this.antic.readReg(a); }],\n [0xd800, 0xffff, 0xffff, (a) => { return this.bios[a - 0xd800]; }],\n ]),\n write: newAddressDecoder([\n [0x0000, 0xbffa, 0xffff, (a, v) => { this.ram[a] = v; }],\n [0xbffb, 0xbfff, 0xffff, (a, v) => { this.ram[a] = v; this.initCartA(); }],\n [0xd000, 0xd0ff, 0x1f, (a, v) => { this.gtia.setReg(a, v); }],\n [0xd200, 0xd2ff, 0xf, (a, v) => { this.writePokey(a, v); }],\n [0xd400, 0xd4ff, 0xf, (a, v) => { this.antic.setReg(a, v); }],\n [0xd500, 0xd5ff, 0xff, (a, v) => { this.writeMapper(a, v); }],\n ]),\n };\n }\n\n loadBIOS(bios: Uint8Array) {\n this.bios.set(bios);\n }\n\n reset() {\n super.reset();\n this.antic.reset();\n this.gtia.reset();\n this.keycode = 0;\n if (this.xexdata) this.cart_a0 = true; // TODO\n }\n\n read(a) {\n // TODO: lastdmabyte?\n return this.bus.read(a);\n }\n // used by ANTIC\n readDMA(a) {\n let v = this.bus.read(a);\n this.probe.logVRAMRead(a, v);\n this.lastdmabyte = v;\n return v;\n }\n readConst(a) {\n return a < 0xd000 || a >= 0xe000 ? this.bus.read(a) : 0xff;\n }\n write(a, v) {\n this.bus.write(a, v);\n }\n readPokey(a: number) {\n switch (a & 0xf) {\n case 9: // KBCODE\n return this.keycode & 0xff;\n case 15: // SKSTAT\n return ((~this.keycode >> 6) & 0x4) | ((~this.keycode >> 3) & 0x8) | 0x12;\n default:\n return this.irq_pokey.read(a);\n }\n }\n readPIA(a: number) {\n if (a == 0 || a == 1) { return ~this.inputs[a]; }\n }\n writePokey(a, v) {\n this.audio_pokey.pokey1.setRegister(a, v);\n this.irq_pokey.write(a, v);\n }\n\n startScanline() {\n // TODO: if (this.antic.h != 0) throw new Error(this.antic.h+\"\");\n //if (this.cpu.isHalted()) throw new EmuHalt(\"CPU HALTED\");\n // set GTIA switch inputs\n this.gtia.sync();\n // TODO: trigger latching mode\n for (let i = 0; i < 4; i++)\n this.gtia.readregs[TRIG0 + i] = (~this.inputs[2] >> i) & 1;\n // console switches\n this.gtia.readregs[CONSOL] = ~this.inputs[3] & 0x7;\n // advance POKEY audio\n this.audio && this.audioadapter.generate(this.audio);\n // advance POKEY IRQ timers\n this.irq_pokey.advanceScanline();\n }\n\n drawScanline() {\n // TODO\n let y = this.antic.v - this.firstVisibleScanline;\n if (y >= 0 && y < this.numVisibleScanlines) {\n this.pixels.set(this.linergb, y * this.canvasWidth);\n }\n }\n\n advanceCPU(): number {\n // update ANTIC\n if (this.antic.clockPulse()) {\n // ANTIC DMA cycle, update GTIA\n this.gtia.updateGfx(this.antic.h - 1, this.lastdmabyte); // HALT pin\n this.probe.logClocks(1);\n } else {\n super.advanceCPU();\n }\n // update GTIA\n // get X coordinate within scanline\n let xofs = this.antic.h * 4 - this.firstVisibleClock;\n // GTIA tick functions\n let gtiatick1 = () => {\n this.gtia.clockPulse1();\n this.linergb[xofs++] = this.gtia.rgb;\n }\n let gtiatick2 = () => {\n this.gtia.clockPulse2();\n this.linergb[xofs++] = this.gtia.rgb;\n }\n // tick 4 GTIA clocks for each CPU/ANTIC cycle\n this.gtia.clockPulse4();\n // correct for HSCROL -- bias antic +2, bias gtia -1\n if ((this.antic.dliop & 0x10) && (this.antic.regs[4] & 1)) {\n xofs += 2;\n this.gtia.setBias(-1);\n } else {\n this.gtia.setBias(0);\n }\n let bp = MODE_SHIFT[this.antic.mode];\n let odd = this.antic.h & 1;\n if (bp < 8 || odd) { this.gtia.an = this.antic.shiftout(); }\n gtiatick1();\n if (bp == 1) { this.gtia.an = this.antic.shiftout(); }\n gtiatick2();\n if (bp <= 2) { this.gtia.an = this.antic.shiftout(); }\n gtiatick1();\n if (bp == 1) { this.gtia.an = this.antic.shiftout(); }\n gtiatick2();\n return 1;\n }\n\n loadState(state: any) {\n this.loadControlsState(state);\n this.cpu.loadState(state.c);\n this.ram.set(state.ram);\n this.antic.loadState(state.antic);\n this.gtia.loadState(state.gtia);\n this.irq_pokey.loadState(state.pokey);\n this.lastdmabyte = state.lastdmabyte;\n this.keycode = state.keycode;\n }\n saveState() {\n return {\n c: this.cpu.saveState(),\n ram: this.ram.slice(0),\n antic: this.antic.saveState(),\n gtia: this.gtia.saveState(),\n pokey: this.irq_pokey.saveState(),\n inputs: this.inputs.slice(0),\n lastdmabyte: this.lastdmabyte,\n keycode: this.keycode,\n };\n }\n loadControlsState(state) {\n this.inputs.set(state.inputs);\n }\n saveControlsState() {\n return {\n inputs: this.inputs.slice(0)\n };\n }\n getRasterScanline() {\n return this.antic.v;\n }\n getRasterLineClock() {\n return this.antic.h;\n }\n getDebugCategories() {\n return ['CPU', 'Stack', 'ANTIC', 'GTIA', 'POKEY'];\n }\n getDebugInfo(category, state) {\n switch (category) {\n case 'ANTIC': return ANTIC.stateToLongString(state.antic);\n case 'GTIA': return GTIA.stateToLongString(state.gtia);\n case 'POKEY': return POKEY.stateToLongString(state.pokey);\n }\n }\n getKeyboardFunction() {\n return (o, key, code, flags) => {\n if (flags & (KeyFlags.KeyDown | KeyFlags.KeyUp)) {\n //console.log(o, key, code, flags, hex(this.keycode));\n var keymap = ATARI8_KEYMATRIX_INTL_NOSHIFT;\n if (key == Keys.VK_F9.c) {\n this.irq_pokey.generateIRQ(0x80); // break IRQ\n return true;\n }\n for (var i = 0; i < keymap.length; i++) {\n if (keymap[i] && keymap[i].c == key) {\n this.keycode = i;\n if (flags & KeyFlags.Shift) { this.keycode |= 0x40; }\n if (flags & KeyFlags.Ctrl) { this.keycode |= 0x80; }\n if (flags & KeyFlags.KeyDown) {\n this.keycode |= 0x100;\n this.irq_pokey.generateIRQ(0x40); // key pressed IRQ\n return true;\n }\n }\n }\n };\n }\n }\n pokey_irq() {\n this.cpu.IRQ();\n this.probe.logInterrupt(2);\n }\n antic_nmi() {\n this.cpu.NMI();\n this.probe.logInterrupt(1);\n }\n\n loadROM(rom: Uint8Array, title: string) {\n // XEX file?\n if (title && title.toLowerCase().endsWith('.xex') && rom[0] == 0xff && rom[1] == 0xff) { \n // TODO: we fake a cartridge\n this.xexdata = rom;\n let cart = new Uint8Array(0x1000);\n cart.set([0x00, 0x01, 0x00, 0x04, 0x00, 0x01], 0xffa);\n this.loadCartridge(cart);\n } else {\n this.loadCartridge(rom);\n }\n }\n\n loadCartridge(rom: Uint8Array) {\n // strip off header\n if (rom[0] == 0x43 && rom[1] == 0x41 && rom[2] == 0x52 && rom[3] == 0x54) {\n rom = rom.slice(16);\n }\n if (rom.length != 0x1000 && rom.length != 0x2000 && rom.length != 0x4000 && rom.length != 0x8000)\n throw new Error(\"Sorry, this platform can only load 4/8/16/32 KB cartridges at the moment.\");\n // TODO: support other than 8 KB carts\n // support 4/8/16/32 KB carts\n let rom2 = new Uint8Array(0x8000);\n for (let i = 0; i <= rom2.length - rom.length; i += rom.length) {\n rom2.set(rom, i);\n }\n this.cart_a0 = true; // TODO\n this.cart_80 = rom.length == 0x4000;\n super.loadROM(rom2);\n }\n\n writeMapper(addr:number, value:number) {\n if (addr == 0xff) {\n if (value == 0x80) this.cart_80 = false;\n if (value == 0xa0) this.cart_a0 = false;\n }\n }\n\n // TODO\n loadXEX(rom: Uint8Array) {\n let ofs = 2;\n let cart = this.ram;\n let cartofs = 0x100; // stub routine in stack page\n while (ofs < rom.length) {\n let start = rom[ofs+0] + rom[ofs+1] * 256;\n let end = rom[ofs+2] + rom[ofs+3] * 256;\n console.log('XEX', ofs, hex(start), hex(end));\n ofs += 4;\n for (let i=start; i<=end; i++) {\n this.ram[i] = rom[ofs++];\n }\n var runaddr = this.ram[0x2e0] + this.ram[0x2e1]*256;\n var initaddr = this.ram[0x2e2] + this.ram[0x2e3]*256;\n console.log('XEX run', hex(runaddr), 'init', hex(initaddr));\n if (initaddr) {\n cart[cartofs++] = 0x20;\n cart[cartofs++] = initaddr & 0xff;\n cart[cartofs++] = initaddr >> 8;\n }\n if (ofs > rom.length) throw new Error(\"Bad .XEX file format\");\n }\n if (runaddr) {\n cart[cartofs++] = 0xa9; // lda #$a0\n cart[cartofs++] = 0xa0;\n cart[cartofs++] = 0x8d; // sta $d5ff (disable cart)\n cart[cartofs++] = 0xff;\n cart[cartofs++] = 0xd5;\n cart[cartofs++] = 0x4c; // jmp runaddr\n cart[cartofs++] = runaddr & 0xff;\n cart[cartofs++] = runaddr >> 8;\n }\n}\n\n initCartA() {\n //console.log('init', hex(this.cpu.getPC()));\n // disable cartridges and load XEX\n if (this.cpu.getPC() == 0xf17f) {\n if (this.xexdata) {\n this.loadXEX(this.xexdata);\n }\n //this.cart_80 = this.cart_a0 = false;\n }\n }\n\n}\n\nexport class Atari5200 extends Atari800 {\n newBus() {\n return {\n read: newAddressDecoder([\n [0x0000, 0x3fff, 0xffff, (a) => { return this.ram[a]; }],\n [0x4000, 0xbfff, 0xffff, (a) => { return this.rom ? this.rom[a - 0x4000] : 0; }],\n [0xc000, 0xcfff, 0x1f, (a) => { return this.gtia.readReg(a); }],\n [0xd400, 0xd4ff, 0xf, (a) => { return this.antic.readReg(a); }],\n [0xe800, 0xefff, 0xf, (a) => { return this.readPokey(a); }],\n [0xf800, 0xffff, 0x7ff, (a) => { return this.bios[a]; }],\n ]),\n write: newAddressDecoder([\n [0x0000, 0x3fff, 0xffff, (a, v) => { this.ram[a] = v; }],\n [0xc000, 0xcfff, 0x1f, (a, v) => { this.gtia.setReg(a, v); }],\n [0xd400, 0xd4ff, 0xf, (a, v) => { this.antic.setReg(a, v); }],\n [0xe800, 0xefff, 0xf, (a, v) => { this.writePokey(a, v); }],\n ]),\n };\n }\n}\n\n///\n\nexport class Atari8_WASMMachine extends BaseWASIMachine\n implements Machine, Probeable, VideoSource, AcceptsROM, FrameBased, AcceptsKeyInput, AcceptsPaddleInput {\n\n numTotalScanlines = 312;\n cpuCyclesPerLine = 63;\n\n prgstart: number;\n joymask0 = 0;\n joymask1 = 0;\n\n loadROM(rom: Uint8Array) {\n super.loadROM(rom);\n this.reloadROM();\n }\n reloadROM() {\n if (this.sys) {\n var result = this.exports.machine_load_rom(this.sys, this.romptr, this.romlen);\n console.log('machine_load_rom', result);\n //console.log(this.wasmFs.fs.existsSync('atari8.img'), result);\n }\n }\n loadBIOS(srcArray: Uint8Array) {\n super.loadBIOS(srcArray);\n }\n reset() {\n this.reloadROM();\n }\n advanceFrame(trap: TrapCondition): number {\n // TODO\n this.exports.machine_start_frame(this.sys);\n if (trap) {\n this.advanceFrameClock(trap, 999999); // TODO?\n } else {\n this.exports.machine_advance_frame(this.sys);\n }\n this.syncVideo();\n this.syncAudio();\n return 1;\n }\n getCPUState() {\n this.exports.machine_save_cpu_state(this.sys, this.stateptr);\n var s = this.statearr;\n var pc = s[6] + (s[7] << 8);\n return {\n PC: pc,\n SP: s[2],\n A: s[0],\n X: s[3],\n Y: s[4],\n C: s[1] & 1,\n Z: s[1] & 2,\n I: s[1] & 4,\n D: s[1] & 8,\n V: s[1] & 64,\n N: s[1] & 128,\n o: this.readConst(pc),\n }\n }\n saveState() {\n var cpu = this.getCPUState();\n this.exports.machine_save_state(this.sys, this.stateptr);\n return {\n c: cpu,\n state: this.statearr.slice(0),\n //ram:this.statearr.slice(18640, 18640+0x200), // ZP and stack\n };\n }\n loadState(state): void {\n this.statearr.set(state.state);\n this.exports.machine_load_state(this.sys, this.stateptr);\n }\n getVideoParams() {\n return { width: 384, height: 240, overscan: true, videoFrequency: 60 };\n }\n pollControls() {\n }\n setKeyInput(key: number, code: number, flags: number): void {\n // modifier flags\n if (flags & KeyFlags.Shift) key |= 0x100;\n if (flags & KeyFlags.Ctrl) key |= 0x200;\n // keyboard -> joystick\n var mask = 0;\n if (key == 37) { key = 0x8; mask = 0x4; } // LEFT\n if (key == 38) { key = 0xb; mask = 0x1; } // UP\n if (key == 39) { key = 0x9; mask = 0x8; } // RIGHT\n if (key == 40) { key = 0xa; mask = 0x2; } // DOWN\n if (key == 32) { mask = 0x100; } // FIRE\n // set machine inputs\n if (flags & KeyFlags.KeyDown) {\n this.exports.machine_key_down(this.sys, key);\n this.joymask0 |= mask;\n } else if (flags & KeyFlags.KeyUp) {\n this.exports.machine_key_up(this.sys, key);\n this.joymask0 &= ~mask;\n }\n this.setJoyInput(0, this.joymask0);\n this.setJoyInput(1, this.joymask1);\n }\n setJoyInput(joy: number, mask: number) {\n this.exports.machine_joy_set(this.sys, joy, mask);\n }\n setPaddleInput(controller: number, value: number): void {\n this.exports.machine_paddle_set(this.sys, controller, value);\n }\n\n}\n\n", "\nimport { Platform, getOpcodeMetadata_6502, getToolForFilename_6502, Base6502MachinePlatform } from \"../common/baseplatform\";\nimport { PLATFORMS, Keys, makeKeycodeMap } from \"../common/emu\";\nimport { BaseMAME6502Platform } from \"../common/mameplatform\";\nimport { Atari5200, Atari800, Atari8_WASMMachine } from \"../machine/atari8\";\n\ndeclare var jt; // for 6502\n\nvar Atari8_PRESETS = [\n {id:'hello.dasm', name:'Hello World (ASM)'},\n {id:'hellopm.dasm', name:'Hello Sprites (ASM)'},\n {id:'helloconio.c', name:'Text Mode (C)'},\n {id:'siegegame.c', name:'Siege Game (C)'},\n {id:'hellodlist.c', name:'Display List (C)'},\n];\n\nvar Atari800_PRESETS = Atari8_PRESETS.concat([\n {id:'sieve.bas', name:'Benchmark (FastBasic)'},\n {id:'pmtest.bas', name:'Sprites Test (FastBasic)'},\n {id:'dli.bas', name:'DLI Test (FastBasic)'},\n {id:'joyas.bas', name:'Match-3 Game (FastBasic)'},\n]);\n\nconst ATARI8_KEYCODE_MAP = makeKeycodeMap([\n [Keys.VK_SPACE, 0, 0],\n [Keys.VK_ENTER, 0, 0],\n]);\n\nconst Atari800_MemoryMap = { main:[\n {name:'RAM',start:0x0,size:0xc000,type:'ram'},\n {name:'Left Cartridge ROM',start:0xa000,size:0x2000,type:'rom'},\n {name:'GTIA',start:0xd000,size:0x20,type:'io'},\n {name:'POKEY',start:0xd200,size:0x10,type:'io'},\n {name:'PIA',start:0xd300,size:0x04,type:'io'},\n {name:'ANTIC',start:0xd400,size:0x10,type:'io'},\n {name:'Cartridge Control Line',start:0xd600,size:0x100,type:'io'},\n {name:'ROM',start:0xd800,size:0x800,type:'rom'},\n {name:'Character Set',start:0xe000,size:0x400,type:'rom'},\n {name:'ROM',start:0xe400,size:0x1c00,type:'rom'},\n] }\n\nfunction getToolForFilename_Atari8(fn:string) {\n if (fn.endsWith(\".bas\") || fn.endsWith(\".fb\") || fn.endsWith(\".fbi\")) return \"fastbasic\";\n else return getToolForFilename_6502(fn);\n}\n\n/// MAME support\n\nabstract class Atari8MAMEPlatform extends BaseMAME6502Platform {\n getPresets() { return Atari8_PRESETS; }\n getToolForFilename = getToolForFilename_Atari8;\n getOpcodeMetadata = getOpcodeMetadata_6502;\n getDefaultExtension() { return \".asm\"; };\n showHelp(tool:string, ident:string) {\n if (tool == 'fastbasic')\n window.open(\"https://github.com/dmsc/fastbasic/blob/master/manual.md\", \"_help\");\n else\n window.open(\"https://atariwiki.org/wiki/Wiki.jsp?page=Assembler\", \"_help\"); // TODO\n }\n}\n\nabstract class Atari8WASIMAMEPlatform extends BaseMAME6502Platform {\n getPresets() { return Atari8_PRESETS; }\n getToolForFilename = getToolForFilename_Atari8;\n getOpcodeMetadata = getOpcodeMetadata_6502;\n getDefaultExtension() { return \".asm\"; };\n showHelp(tool:string, ident:string) {\n if (tool == 'fastbasic')\n window.open(\"https://github.com/dmsc/fastbasic/blob/master/manual.md\", \"_help\");\n else\n window.open(\"https://atariwiki.org/wiki/Wiki.jsp?page=Assembler\", \"_help\"); // TODO\n }\n}\n\nclass Atari800MAMEPlatform extends Atari8MAMEPlatform implements Platform {\n getPresets() { return Atari800_PRESETS; }\n loadROM(title, data) {\n if (!this.started) {\n this.startModule(this.mainElement, {\n jsfile:'mame8bitws.js',\n biosfile:'a800xl.zip',\n cfgfile:'a800xl.cfg',\n driver:'a800xl',\n width:336*2,\n height:225*2,\n romfn:'/emulator/cart.rom',\n romdata:new Uint8Array(data),\n romsize:0x2000,\n preInit:function(_self) {\n },\n });\n } else {\n this.loadROMFile(data);\n this.loadRegion(\":cartleft:cart:rom\", data);\n }\n }\n start() {\n }\n getMemoryMap = function() { return Atari800_MemoryMap };\n}\n\nclass Atari5200MAMEPlatform extends Atari8MAMEPlatform implements Platform {\n loadROM(title, data) {\n if (!this.started) {\n this.startModule(this.mainElement, {\n jsfile:'mame8bitws.js',\n biosfile:'a5200/5200.rom',\n cfgfile:'a5200.cfg',\n driver:'a5200',\n width:336*2,\n height:225*2,\n romfn:'/emulator/cart.rom',\n romdata:new Uint8Array(data),\n romsize:0x8000,\n preInit:function(_self) {\n },\n });\n } else {\n this.loadROMFile(data);\n this.loadRegion(\":cartleft:cart:rom\", data);\n }\n }\n start() {\n }\n getMemoryMap = function() { return { main:[\n {name:'RAM',start:0x0,size:0x4000,type:'ram'},\n {name:'Cartridge ROM',start:0x4000,size:0x8000,type:'rom'},\n {name:'GTIA',start:0xc000,size:0x20,type:'io'},\n {name:'ANTIC',start:0xd400,size:0x10,type:'io'},\n {name:'POKEY',start:0xe800,size:0x10,type:'io'},\n {name:'ATARI Character Set',start:0xf800,size:0x400,type:'rom'},\n {name:'ROM',start:0xfc00,size:0x400,type:'rom'},\n ] } };\n}\n\n/// WASM Atari8 platform\nclass Atari8WASMPlatform extends Base6502MachinePlatform<Atari8_WASMMachine> implements Platform {\n\n newMachine() { return new Atari8_WASMMachine('atari8'); }\n getPresets() { return Atari800_PRESETS; }\n getDefaultExtension() { return \".c\"; };\n getToolForFilename = getToolForFilename_Atari8;\n readAddress(a) { return this.machine.readConst(a); }\n getMemoryMap() { return Atari800_MemoryMap; }\n showHelp() {\n // TODO\n }\n getROMExtension(rom:Uint8Array) { \n // TODO\n if (rom && rom[0] == 0x01 && rom[1] == 0x08) return \".prg\";\n else return \".bin\";\n }\n}\n\nclass Atari800WASMPlatform extends Atari8WASMPlatform { \n}\n\n////\n\nclass Atari800Platform extends Base6502MachinePlatform<Atari800> {\n newMachine() { return new Atari800(); }\n getPresets() { return Atari800_PRESETS; }\n getDefaultExtension() { return \".c\"; };\n getToolForFilename = getToolForFilename_Atari8;\n readAddress(a) { return this.machine.readConst(a); }\n getMemoryMap() { return Atari800_MemoryMap; }\n showHelp() {\n // TODO\n }\n getROMExtension(rom:Uint8Array) { \n // TODO\n if (rom && rom[0] == 0x01 && rom[1] == 0x08) return \".prg\";\n else return \".bin\";\n }\n async start() {\n let bios = await this.loadKernel();\n await super.start();\n this.machine.loadBIOS(bios);\n }\n biosPath = 'res/altirra/kernel.rom';\n async loadKernel() {\n var biosResponse = await fetch(this.biosPath);\n if (biosResponse.status == 200 || (biosResponse as any as Blob).size) {\n var biosBinary = await biosResponse.arrayBuffer();\n return new Uint8Array(biosBinary);\n } else throw new Error('could not load BIOS file');\n }\n}\n\nclass Atari5200Platform extends Atari800Platform {\n newMachine() { return new Atari5200(); }\n biosPath = 'res/altirra/superkernel.rom';\n}\n\n///\n\nPLATFORMS['atari8-800.xlmame'] = Atari800MAMEPlatform\nPLATFORMS['atari8-800xl.mame'] = Atari800MAMEPlatform // for dithertron\nPLATFORMS['atari8-5200.mame'] = Atari5200MAMEPlatform\nPLATFORMS['atari8-800.xlwasm'] = Atari800WASMPlatform\nPLATFORMS['atari8-800'] = Atari800Platform\nPLATFORMS['atari8-5200'] = Atari5200Platform\n"],
"mappings": "sRAYA,GAAM,IAAU,CAAC,EAAG,GAAI,GAAI,GACtB,GAAW,CAAC,EAAG,GAAK,GAAI,GAAK,GAAI,EAAI,IAErC,EAAS,EACT,GAAS,EACT,EAAS,EACT,EAAS,EACT,GAAS,EACT,GAAS,EACT,GAAS,EACT,GAAS,EACT,EAAQ,GACR,GAAS,GACT,GAAO,GACP,GAAO,GACP,GAAQ,GACR,GAAS,GACT,EAAQ,GAWd,GAAM,IAAa,GAAK,EAClB,GAAc,IAAM,EACpB,GAAa,IAEb,GAAa,CAAC,EAAG,EAAG,EAAG,GAAI,EAAG,GAAI,EAAG,GAAI,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,GAE9D,GAAc,CAAC,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAA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