"use strict"; import { Platform, Base6502Platform, BaseMAMEPlatform, getOpcodeMetadata_6502, cpuStateToLongString_6502, getToolForFilename_6502, dumpStackToString, ProfilerOutput } from "../baseplatform"; import { PLATFORMS, RAM, newAddressDecoder, padBytes, noise, setKeyboardFromMap, AnimationTimer, RasterVideo, Keys, makeKeycodeMap, dumpRAM, KeyFlags, EmuHalt } from "../emu"; import { hex, lpad, lzgmini, byteArrayToString } from "../util"; import { CodeAnalyzer_nes } from "../analysis"; import { SampleAudio } from "../audio"; declare var jsnes : any; const JSNES_PRESETS = [ {id:'hello.c', name:'Hello World'}, {id:'scroll.c', name:'Scrolling'}, {id:'vrambuffer.c', name:'VRAM Buffer'}, {id:'sprites.c', name:'Sprites'}, {id:'metasprites.c', name:'Metasprites'}, {id:'flicker.c', name:'Flickering Sprites'}, {id:'metacursor.c', name:'Controllers'}, {id:'rletitle.c', name:'Title Screen RLE'}, {id:'statusbar.c', name:'Split Status Bar'}, {id:'horizmask.c', name:'Offscreen Scrolling'}, {id:'monobitmap.c', name:'Monochrome Bitmap'}, {id:'aputest.c', name:'Sound Tester'}, {id:'music.c', name:'Music Player'}, {id:'siegegame.c', name:'Siege Game'}, {id:'shoot2.c', name:'Solarian Game'}, {id:'climber.c', name:'Platform Game'}, {id:'fami.c', name:'Famitone Demo'}, {id:'bankswitch.c', name:'Bank Switching'}, {id:'irq.c', name:'IRQ Scanline Counter'}, {id:'ex0.asm', name:'Initialization (ASM)'}, {id:'ex1.asm', name:'Hello World (ASM)'}, {id:'ex2.asm', name:'Scrolling Demo (ASM)'}, {id:'ex3.asm', name:'Sprite Demo (ASM)'}, {id:'ex4.asm', name:'Controller Demo (ASM)'}, {id:'musicdemo.asm', name:'Famitone Demo (ASM)'}, {id:'scrollrt.asm', name:'Line-by-line Scrolling (ASM)'}, {id:'xyscroll.asm', name:'XY Split Scrolling (ASM)'}, ]; /// JSNES const JSNES_KEYCODE_MAP = makeKeycodeMap([ [Keys.VK_X, 0, 0], [Keys.VK_Z, 0, 1], [Keys.VK_SPACE, 0, 2], [Keys.VK_ENTER, 0, 3], [Keys.VK_UP, 0, 4], [Keys.VK_DOWN, 0, 5], [Keys.VK_LEFT, 0, 6], [Keys.VK_RIGHT, 0, 7], [Keys.VK_Q, 1, 0], [Keys.VK_E, 1, 1], [Keys.VK_4, 1, 2], [Keys.VK_3, 1, 3], [Keys.VK_W, 1, 4], [Keys.VK_S, 1, 5], [Keys.VK_A, 1, 6], [Keys.VK_D, 1, 7], ]); class JSNESPlatform extends Base6502Platform implements Platform { mainElement; nes; video; audio; timer; audioFrequency = 44030; //44100 frameindex = 0; ntvideo; ntlastbuf; constructor(mainElement) { super(); this.mainElement = mainElement; } getPresets() { return JSNES_PRESETS; } start() { this.debugPCDelta = 1; var debugbar = $("
").appendTo(this.mainElement); this.audio = new SampleAudio(this.audioFrequency); this.video = new RasterVideo(this.mainElement,256,224,{overscan:true}); this.video.create(); // debugging view this.ntvideo = new RasterVideo(this.mainElement,512,480,{overscan:false}); this.ntvideo.create(); $(this.ntvideo.canvas).hide(); this.ntlastbuf = new Uint32Array(0x1000); // toggle buttons (TODO) $('