public m085(NESCore nes, byte reg1, byte altReg1) { this.nes = nes; this.cycleIRQ = true; regAddr = reg1; altRegAddr = altReg1; }
public NSF(NESCore nes, int specialChips) { this.nes = nes; chipCount = 0; if ((FlagVRC6 & specialChips) != 0) { VRC6 = new Channels.VRC6(0, 1, 2, 3); chipCount++; } else { VRC6 = new Channels.External(); } if ((FlagVRC7 & specialChips) != 0) { VRC7 = new Channels.External(); chipCount++; } else { VRC7 = new Channels.External(); } if ((FlagFDS & specialChips) != 0) { FDS = new Channels.FDS(); chipCount++; } else { FDS = new Channels.External(); } if ((FlagMMC5 & specialChips) != 0) { hasMMC5 = true; MMC5 = new Channels.MMC5(nes); chipCount++; } else { MMC5 = new Channels.External(); } if ((FlagN163 & specialChips) != 0) { N163 = new Channels.N163(); chipCount++; } else { N163 = new Channels.External(); } if ((FlagFME7 & specialChips) != 0) { FME7 = new Channels.FME7(); chipCount++; } else { FME7 = new Channels.External(); } }
public DWindow(NES6502 cpu, Cart cr, NESCore nes) { this.cpu = cpu; this.cr = cr; this.nes = nes; InitializeComponent(); }
public MainForm() { InitializeComponent(); // Setup the real-time renderer to run when Application_Idle is fired. Application.Idle += Application_Idle; _Bitmap = new DirectBitmap(780, 480, PixelFormat.Format32bppArgb); _TimeUtil = new TimeUtil(); _FpsUtil = new FPSUtil(); _InputUtil = new InputUtil(); this.KeyDown += _InputUtil.OnKeyDown; this.KeyUp += _InputUtil.OnKeyUp; // Assign the DirectBitmap to the pixturebox pictureBox1.Image = _Bitmap.bitmap; _DrawFont = new Font("Courier New", 9); _StringBuilder = new StringBuilder(); _DrawOnBrush = new SolidBrush(Color.Yellow); _DrawOffBrush = new SolidBrush(Color.Gray); _NESCore = new NESCore(); }
public m019(NESCore nes) { this.nes = nes; this.cycleIRQ = true; if (nes.rom.mapper == 19) nes.APU.external = new Channels.N163(); }
public void Update(NESCore nes) { this.nes = nes; if (timer++ % 6 == 0) { Redraw(); } }
public m022(NESCore nes) { this.nes = nes; regAddr[0] = 0; regAddr[1] = 2; regAddr[2] = 1; regAddr[3] = 3; }
public m019(NESCore nes) { this.nes = nes; this.cycleIRQ = true; if (nes.rom.mapper == 19) { nes.APU.external = new Channels.N163(); } }
public mVRC6(NESCore nes, byte reg1, byte reg2, byte reg3, byte reg4) { this.nes = nes; this.cycleIRQ = true; regAddr[0] = reg1; regAddr[1] = reg2; regAddr[2] = reg3; regAddr[3] = reg4; this.nes.APU.external = new Channels.VRC6(reg1, reg2, reg3, reg4); }
public Debug(NESCore nes) { this.nes = nes; square1History = new byte[historySamplesPerFrame]; square2History = new byte[historySamplesPerFrame]; triangleHistory = new byte[historySamplesPerFrame]; noiseHistory = new byte[historySamplesPerFrame]; dmcHistory = new byte[historySamplesPerFrame]; externalHistory = new byte[historySamplesPerFrame]; }
public APU(NESCore nes, int sampleRate) { this.nes = nes; this.sampleRate = sampleRate; switch (nes.nesRegion) { default: case SystemType.NTSC: CPUClock = 1789773; FPS = (CPUClock * 3.0) / 89341.5; modeZeroDelay = 7459;//http://nesdev.parodius.com/bbs/viewtopic.php?p=64281#64281 modeZeroFrameLengths = new int[] { 7456, 7458, 7458, 7458 }; modeOneDelay = 1; modeOneFrameLengths = new int[] { 7458, 7456, 7458, 7458, 7452 }; break; case SystemType.PAL: CPUClock = 1662607; FPS = (CPUClock * 3.2) / 106392; modeZeroDelay = 8315; modeZeroFrameLengths = new int[] { 8314, 8312, 8314, 8314 }; modeOneDelay = 1; modeOneFrameLengths = new int[] { 8314, 8314, 8312, 8314, 8312 }; break; } if (this.sampleRate == -1) { this.sampleRate = CPUClock; } rollingAveWindow = this.sampleRate / 10; SetFPS(FPS); output = new short[this.sampleRate]; //the buffers really don't need to be this large, but it should prevent overflows when the FPS is set exceptionally low. for (int i = 0; i < 32; i++) { pulseTable[i] = ((95.52 / (8128.0 / i + 100.0))); pulseTableShort[i] = (int)(pulseTable[i] * 0x7FFF); //Half the range for internal channels, half for external. } for (int i = 0; i < 204; i++) { tndTable[i] = ((163.67 / (24329.0 / i + 100.0))); tndTableShort[i] = (int)(tndTable[i] * 0x7FFF); } volume.square1 = 1; volume.square2 = 1; volume.triangle = 1; volume.noise = 1; volume.dmc = 1; volume.external = 1; square1 = new Channels.Square(nes, true, true); square2 = new Channels.Square(nes, true, false); triangle = new Channels.Triangle(nes); noise = new Channels.Noise(nes); dmc = new Channels.DMC(nes, CPUClock); external = new Channels.External(); }
public mNSF(NESCore nes, byte[] banks, int PBRATE, int specialChip) { this.nes = nes; this.cycleIRQ = true; this.speed = (nes.APU.CPUClock * 1.0) / (1000000.0 / (PBRATE * 1.0)); for (int i = 0; i < 8; i++) if (banks[i] != 0) bankSwitching = true; initialBanks = banks; nes.APU.external = new Channels.NSF(nes, specialChip); }
public m185(NESCore nes) { this.nes = nes; for (int i = 0; i < 0x400; i++) { disabledChrBank[i] = 0x12; } for (int i = 0; i < 8; i++) { chrBanks[i] = nes.PPU.PPUMemory.banks[nes.PPU.PPUMemory.swapOffset + i]; } }
public APU(NESCore nes, int sampleRate) { this.nes = nes; this.sampleRate = sampleRate; switch (nes.nesRegion) { default: case SystemType.NTSC: CPUClock = 1789773; FPS = (CPUClock * 3.0) / 89341.5; modeZeroDelay = 7459;//http://nesdev.parodius.com/bbs/viewtopic.php?p=64281#64281 modeZeroFrameLengths = new int[] { 7456, 7458, 7458, 7458}; modeOneDelay = 1; modeOneFrameLengths = new int[] { 7458, 7456, 7458, 7458, 7452}; break; case SystemType.PAL: CPUClock = 1662607; FPS = (CPUClock * 3.2) / 106392; modeZeroDelay = 8315; modeZeroFrameLengths = new int[] { 8314, 8312, 8314, 8314 }; modeOneDelay = 1; modeOneFrameLengths = new int[] { 8314, 8314, 8312, 8314, 8312 }; break; } if (this.sampleRate == -1) this.sampleRate = CPUClock; rollingAveWindow = this.sampleRate / 10; SetFPS(FPS); output = new short[this.sampleRate]; //the buffers really don't need to be this large, but it should prevent overflows when the FPS is set exceptionally low. for (int i = 0; i < 32; i++) { pulseTable[i] = ((95.52 / (8128.0 / i + 100.0))); pulseTableShort[i] = (int)(pulseTable[i] * 0x7FFF); //Half the range for internal channels, half for external. } for (int i = 0; i < 204; i++) { tndTable[i] = ((163.67 / (24329.0 / i + 100.0))); tndTableShort[i] = (int)(tndTable[i] * 0x7FFF); } volume.square1 = 1; volume.square2 = 1; volume.triangle = 1; volume.noise = 1; volume.dmc = 1; volume.external = 1; square1 = new Channels.Square(nes, true, true); square2 = new Channels.Square(nes, true, false); triangle = new Channels.Triangle(nes); noise = new Channels.Noise(nes); dmc = new Channels.DMC(nes, CPUClock); external = new Channels.External(); }
public FamiPaddle(NESCore nes, Port port) //I know this plugged into the expandsion port, but if I dont have a player number how do I know who's keybinds to use? { this.nes = nes; this.port = port; if (port == Port.PortOne) { playerNum = 0; } else if (port == Port.PortTwo) { playerNum = 1; } }
public mVRC4(NESCore nes, byte reg1, byte reg2, byte reg3, byte reg4, byte altReg1, byte altReg2, byte altReg3, byte altReg4) { this.nes = nes; this.cycleIRQ = true; regAddr[0] = reg1; regAddr[1] = reg2; regAddr[2] = reg3; regAddr[3] = reg4; altRegAddr[0] = altReg1; altRegAddr[1] = altReg2; altRegAddr[2] = altReg3; altRegAddr[3] = altReg4; }
public Zapper(NESCore nes, Port port) { this.nes = nes; this.port = port; if (port == Port.PortOne) { playerNum = 0; } else if (port == Port.PortTwo) { playerNum = 1; } }
public Paddle(NESCore nes, Port port) { this.nes = nes; this.port = port; if (port == Port.PortOne) { playerNum = 0; } else if (port == Port.PortTwo) { playerNum = 1; } }
public Noise(NESCore nes) { this.nes = nes; switch (nes.nesRegion) { default: case SystemType.NTSC: periods = new ushort[] { 4, 8, 16, 32, 64, 96, 128, 160, 202, 254, 380, 508, 762, 1016, 2034, 4068 }; break; case SystemType.PAL: periods = new ushort[] { 4, 7, 14, 30, 60, 88, 118, 148, 188, 236, 354, 472, 708, 944, 1890, 3778 }; break; } }
public DMC(NESCore nes, int bufferSize) { this.nes = nes; switch (nes.nesRegion) { default: case SystemType.NTSC: rates = new int[] { 428, 380, 340, 320, 286, 254, 226, 214, 190, 160, 142, 128, 106, 84, 72, 54 }; break; case SystemType.PAL: rates = new int[] { 398, 354, 316, 298, 276, 236, 210, 198, 176, 148, 132, 118, 98, 78, 66, 50 }; break; } buffer = new byte[bufferSize]; }
public mNSF(NESCore nes, byte[] banks, int PBRATE, int specialChip) { this.nes = nes; this.cycleIRQ = true; this.speed = (nes.APU.CPUClock * 1.0) / (1000000.0 / (PBRATE * 1.0)); for (int i = 0; i < 8; i++) { if (banks[i] != 0) { bankSwitching = true; } } initialBanks = banks; nes.APU.external = new Channels.NSF(nes, specialChip); }
public m020(NESCore nes, Stream diskStream, bool ignoreFileCheck) { this.nes = nes; this.cycleIRQ = true; diskStream.Position = 0x0; if (!ignoreFileCheck) { if (diskStream.ReadByte() != 'F' || diskStream.ReadByte() != 'D' || diskStream.ReadByte() != 'S' || diskStream.ReadByte() != 0x1A) { diskStream.Position = 0x0; if (diskStream.ReadByte() != 0x01 || diskStream.ReadByte() != '*' || diskStream.ReadByte() != 'N' || diskStream.ReadByte() != 'I') { diskStream.Close(); throw (new BadHeaderException("Invalid File")); } else //NoIntro set uses many headerless roms which makes sense given how useless the header is. { diskStream.Position = 0x0; sideCount = (int)(diskStream.Length / 65500); } } else { diskStream.Position = 0x4; sideCount = diskStream.ReadByte(); diskStream.Position = 0x10; } } diskData = new byte[sideCount, 65500]; crc = 0xFFFFFFFF; for (int side = 0; side < sideCount; side++) { for (int i = 0; i < 65500; i++) { byte nextByte = (byte)diskStream.ReadByte(); diskData[side, i] = nextByte; crc = CRC32.crc32_adjust(crc, nextByte); } } nes.debug.LogInfo("Disk Sides: " + sideCount.ToString()); crc = crc ^ 0xFFFFFFFF; nes.APU.external = new Channels.FDS(); }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "NES Roms (*.nes)|*.nes"; if (ofd.ShowDialog() == DialogResult.OK) { fileName = ofd.FileName; //START INIT CODE cr = cs.ReadCart(fileName); nes = new NESCore(cr); cpu = new NES6502(cr, nes); ren = new BMP16Renderer(cr); ppu = new PPUCore(cr, ren); cpu.pc_reg = nes.GetResetAddr(); //END INIT CODE MessageBox.Show("PRG ROM loaded!!!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information); buttons(true); } }
public m033(NESCore nes) { this.nes = nes; }
public unsafe void Update(NESCore nes) { this.nes = nes; if (nes.APU.volume.square1 != 0) chanColors[0] = blue; else chanColors[0] = grey; if (nes.APU.volume.square2 != 0) chanColors[1] = blue; else chanColors[1] = grey; if (nes.APU.volume.triangle != 0) chanColors[2] = blue; else chanColors[2] = grey; if (nes.APU.volume.noise != 0) chanColors[3] = blue; else chanColors[3] = grey; if (nes.APU.volume.dmc != 0) chanColors[4] = blue; else chanColors[4] = grey; if (nes.APU.volume.external != 0) chanColors[5] = blue; else chanColors[5] = grey; int blueCount = 0; int blueItem = -1; for(int i = 0; i < 6; i++) if(chanColors[i] == blue) { blueItem = i; blueCount++; } if (blueCount == 1) chanColors[blueItem] = darkBlue; var bmd = screenBuffer.LockBits(new Rectangle(0, 0, 384, 256), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); uint* ptr = (uint*) bmd.Scan0; for (int i = 0; i < 384 * 256; i++) ptr[i] = 0xFF000000; Point lastPoint; for (int channel = 0; channel < 6; channel++) { switch (channel) { case 0: case 1: case 2: case 3: byte[] volume; switch (channel) { default: case 0: volume = nes.debug.square1History; break; case 1: volume = nes.debug.square2History; break; case 2: volume = nes.debug.triangleHistory; break; case 3: volume = nes.debug.noiseHistory; break; } lastPoint = new Point(-1,0); for (int x = 0; x < 128; x++) { Point newPoint = new Point(x + ((channel % 3) * 128), ((channel / 3) * 128) + ((15 - volume[x]) * 8)); if (channel != 2) { if (lastPoint.X != -1) { DrawLine(lastPoint.X + 1, lastPoint.Y, newPoint.X, newPoint.Y, ptr, chanColors[channel]); } else { DrawPixel(ptr, newPoint.X, newPoint.Y, chanColors[channel]); } } else if (lastPoint.X != -1) { DrawLine(lastPoint.X, lastPoint.Y, newPoint.X, newPoint.Y, ptr, chanColors[channel]); } lastPoint = newPoint; } break; case 4: lastPoint = new Point(-1, 0); for (int x = 0; x < 128; x++) { Point newPoint = new Point(x + ((channel % 3) * 128), ((channel / 3) * 128) + ((127 - nes.debug.dmcHistory[x]))); if (lastPoint.X != -1) { DrawLine(lastPoint.X, lastPoint.Y, newPoint.X, newPoint.Y, ptr, chanColors[channel]); } lastPoint = newPoint; } break; case 5: lastPoint = new Point(-1, 0); for (int x = 0; x < 128; x++) { Point newPoint = new Point(x + ((channel % 3) * 128), ((channel / 3) * 128) + ((127 - (nes.debug.externalHistory[x] >> 1)))); if (lastPoint.X != -1) { DrawLine(lastPoint.X, lastPoint.Y, newPoint.X, newPoint.Y, ptr, chanColors[channel]); } lastPoint = newPoint; } break; } } screenBuffer.UnlockBits(bmd); screenGfx.DrawImageUnscaled(screenBuffer, 0,0); }
public m099(NESCore nes) { this.nes = nes; }
public m004(NESCore nes) { this.nes = nes; }
public m011(NESCore nes) { this.nes = nes; }
public m228(NESCore nes) { this.nes = nes; }
public NSFScreen(NESCore nes) { this.nes = nes; LoadCharSheet(); }
public Square(NESCore nes, bool sweep, bool negate) { this.nes = nes; this.negate = negate; this.sweep = sweep; //Allows for reuse as MMC5 square }
public m105(NESCore nes) { this.nes = nes; this.cycleIRQ = true; }
public m066(NESCore nes) { this.nes = nes; }
public m069(NESCore nes) { this.nes = nes; this.cycleIRQ = true; this.nes.APU.external = new Channels.FME7(); }
public SPPU(NESCore nes) { this.nes = nes; int vRAM = 0; if (nes.rom.vROM == 0 || nes.rom.mapper == 19 || nes.rom.mapper == 210) vRAM += 8; PPUMemory = new MemoryStore(4, nes.rom.vROM, vRAM, true); //4 hardwired to make doing extra nametables less insane. for (int i = 0; i < 256; i++) zeroGray[i] = 0x3F; switch (nes.nesRegion) { default: case SystemType.NTSC: vblankEnd = 261; break; case SystemType.PAL: vblankEnd = 312; break; } }
public m152(NESCore nes) { this.nes = nes; }
public m071(NESCore nes) { this.nes = nes; }
public m048(NESCore nes) { this.nes = nes; }
public m005(NESCore nes) { this.nes = nes; nes.APU.external = new Channels.MMC5(nes); }
public PPU(NESCore nes) { this.nes = nes; int vRAM = 0; if (nes.rom.vROM == 0 || nes.rom.mapper == 19 || nes.rom.mapper == 210) vRAM += 8; PPUMemory = new MemoryStore(4, nes.rom.vROM, vRAM, true); //4 hardwired to make doing extra nametables less insane. switch (nes.nesRegion) { default: case SystemType.NTSC: vblankEnd = 261; break; case SystemType.PAL: vblankEnd = 311; break; } horzFlipTable = new byte[256]; for (int i = 0; i < 256; i++) { horzFlipTable[i] = 0; if ((i & 0x80) != 0) horzFlipTable[i] |= 0x01; if ((i & 0x40) != 0) horzFlipTable[i] |= 0x02; if ((i & 0x20) != 0) horzFlipTable[i] |= 0x04; if ((i & 0x10) != 0) horzFlipTable[i] |= 0x08; if ((i & 0x08) != 0) horzFlipTable[i] |= 0x10; if ((i & 0x04) != 0) horzFlipTable[i] |= 0x20; if ((i & 0x02) != 0) horzFlipTable[i] |= 0x40; if ((i & 0x01) != 0) horzFlipTable[i] |= 0x80; } }
public Unisystem(NESCore nes) { this.nes = nes; }
public m079(NESCore nes) { this.nes = nes; }
public m086(NESCore nes) { this.nes = nes; }
public m113(NESCore nes) { this.nes = nes; }
public m080(NESCore nes) { this.nes = nes; }
public m067(NESCore nes) { this.nes = nes; this.cycleIRQ = true; }
public m007(NESCore nes) { this.nes = nes; }
public Triangle(NESCore nes) { this.nes = nes; }