"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const baseplatform_1 = require("../common/baseplatform"); const emu_1 = require("../common/emu"); const util_1 = require("../common/util"); const analysis_1 = require("../common/analysis"); const audio_1 = require("../common/audio"); const probe_1 = require("../common/probe"); const devices_1 = require("../common/devices"); const Mousetrap = require("mousetrap"); const jsnes = require("../../jsnes"); const mameplatform_1 = require("../common/mameplatform"); const JSNES_PRESETS = [ { id: 'hello.c', name: 'Hello World' }, { id: 'attributes.c', name: 'Attribute Table' }, { id: 'scroll.c', name: 'Scrolling' }, { id: 'sprites.c', name: 'Sprites' }, { id: 'metasprites.c', name: 'Metasprites' }, { id: 'flicker.c', name: 'Flickering Sprites' }, { id: 'metacursor.c', name: 'Controllers' }, { id: 'vrambuffer.c', name: 'VRAM Buffer' }, { id: 'statusbar.c', name: 'Split Status Bar' }, { id: 'siegegame.c', name: 'Siege Game' }, { id: 'tint.c', name: 'Color Emphasis' }, { id: 'rletitle.c', name: 'Title Screen RLE' }, { id: 'aputest.c', name: 'Sound Tester' }, { id: 'music.c', name: 'Music Player' }, { id: 'horizscroll.c', name: 'Offscreen Scrolling' }, { id: 'monobitmap.c', name: 'Monochrome Bitmap' }, { id: 'fami.c', name: 'Famitone Demo' }, { id: 'shoot2.c', name: 'Solarian Game' }, { id: 'climber.c', name: 'Climber Game' }, { id: 'bankswitch.c', name: 'Bank Switching' }, { id: 'irq.c', name: 'IRQ Scanline Counter' }, { id: 'ex0.dasm', name: 'Initialization', category: 'Assembly Language (ASM)' }, { id: 'ex1.dasm', name: 'Hello World' }, { id: 'ex2.dasm', name: 'Scrolling Demo' }, { id: 'ex3.dasm', name: 'Sprite Demo' }, { id: 'ex4.dasm', name: 'Controller Demo' }, { id: 'musicdemo.dasm', name: 'Famitone Demo' }, { id: 'xyscroll.dasm', name: 'XY Split Scrolling' }, // {id:'scrollrt.dasm', name:'Line-by-line Scrolling'}, { id: 'road.dasm', name: '3-D Road Demo' }, { id: 'chase/game.c', name: 'Shiru\'s Chase Game', category: 'Other' }, { id: 'hello.wiz', name: 'Hello (Wiz)' }, ]; /// JSNES const JSNES_KEYCODE_MAP = (0, emu_1.makeKeycodeMap)([ [emu_1.Keys.A, 0, 0], [emu_1.Keys.B, 0, 1], [emu_1.Keys.GP_A, 0, 0], [emu_1.Keys.GP_B, 0, 1], [emu_1.Keys.SELECT, 0, 2], [emu_1.Keys.START, 0, 3], [emu_1.Keys.UP, 0, 4], [emu_1.Keys.DOWN, 0, 5], [emu_1.Keys.LEFT, 0, 6], [emu_1.Keys.RIGHT, 0, 7], [emu_1.Keys.P2_A, 1, 0], [emu_1.Keys.P2_B, 1, 1], [emu_1.Keys.P2_SELECT, 1, 2], [emu_1.Keys.P2_START, 1, 3], [emu_1.Keys.P2_UP, 1, 4], [emu_1.Keys.P2_DOWN, 1, 5], [emu_1.Keys.P2_LEFT, 1, 6], [emu_1.Keys.P2_RIGHT, 1, 7], ]); class JSNESPlatform extends baseplatform_1.Base6502Platform { constructor(mainElement) { super(); this.audioFrequency = 44030; //44100 this.frameindex = 0; this.machine = { cpuCyclesPerLine: 114 }; // TODO: hack for width of probe scope this.getToolForFilename = (fn) => { //if (fn.endsWith(".asm")) return "ca65"; // .asm uses ca65 if (fn.endsWith(".nesasm")) return "nesasm"; else return (0, baseplatform_1.getToolForFilename_6502)(fn); }; // probing this.nullProbe = new devices_1.NullProbe(); this.probe = this.nullProbe; this.getMemoryMap = function () { return { main: [ { name: 'Zero Page RAM', start: 0x0, size: 0x100, type: 'ram' }, { name: 'OAM Buffer', start: 0x200, size: 0x100, type: 'ram' }, { name: 'Work RAM', start: 0x300, size: 0x1000 - 0x300, type: 'ram' }, { name: 'PPU Registers', start: 0x2000, last: 0x2008, size: 0x2000, type: 'io' }, { name: 'APU Registers', start: 0x4000, last: 0x4020, size: 0x2000, type: 'io' }, { name: 'Optional Cartridge RAM', start: 0x6000, size: 0x2000, type: 'ram' }, ] }; }; this.mainElement = mainElement; } getPresets() { return JSNES_PRESETS; } start() { this.debugPCDelta = 1; var debugbar = $("
").appendTo(this.mainElement); this.audio = new audio_1.SampleAudio(this.audioFrequency); this.video = new emu_1.RasterVideo(this.mainElement, 256, 224, { overscan: true }); this.video.create(); // debugging view this.ntvideo = new emu_1.RasterVideo(this.mainElement, 512, 480, { overscan: false }); this.ntvideo.create(); $(this.ntvideo.canvas).hide(); this.ntlastbuf = new Uint32Array(0x1000); if (Mousetrap.bind) Mousetrap.bind('ctrl+shift+alt+n', () => { $(this.video.canvas).toggle(); $(this.ntvideo.canvas).toggle(); }); // toggle buttons (TODO) /* $('