"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 } from "../emu"; import { hex, lpad, lzgmini } from "../util"; import { CodeAnalyzer_nes } from "../analysis"; import { SampleAudio } from "../audio"; declare var jsnes : any; const JSNES_PRESETS = [ {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:'neslib1.c', name:'Text'}, {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:'metatrigger.c', name:'Trigger Mode + Vbright'}, {id:'neslib5.c', name:'RLE Unpack'}, {id:'statusbar.c', name:'Split Status Bar'}, {id:'horizmask.c', name:'Horizontal Scrolling'}, {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:'scrollrt.asm', name:'Split Screen Scroll (ASM)'}, {id:'fami.c', name:'Famitone Demo'}, {id:'musicdemo.asm', name:'Famitone Demo (ASM)'}, ]; const NES_NESLIB_PRESETS = [ {id:'neslib1.c', name:'Text'}, {id:'neslib2.c', name:'Sprites'}, {id:'neslib3.c', name:'Cursor'}, {id:'neslib4.c', name:'Metasprites'}, {id:'chase/game.c', name:'Chase (example game)'}, ]; const NES_CONIO_PRESETS = [ {id:'ex0.asm', name:'ASM: Initialization'}, {id:'ex1.asm', name:'ASM: Scrolling Demo'}, {id:'hello.c', name:'C: Hello PPU'}, {id:'conio.c', name:'C: Hello Console I/O'}, {id:'siegegame.c', name:'C: Siege Game'}, ]; /// JSNES const JSNES_KEYCODE_MAP = makeKeycodeMap([ [Keys.VK_Z, 0, 0], [Keys.VK_X, 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], ]); const _JSNESPlatform = function(mainElement) { var nes; var rom; var video, audio, timer; const audioFrequency = 44030; //44100 var frameindex = 0; var ntvideo; var ntlastbuf; class JSNESPlatform extends Base6502Platform implements Platform { getPresets() { return JSNES_PRESETS; } start() { this.debugPCDelta = 1; var debugbar = $("
").appendTo(mainElement); audio = new SampleAudio(audioFrequency); video = new RasterVideo(mainElement,256,224,{overscan:true}); video.create(); // debugging view ntvideo = new RasterVideo(mainElement,512,480,{overscan:false}); ntvideo.create(); $(ntvideo.canvas).hide(); ntlastbuf = new Uint32Array(0x1000); // toggle buttons $('