misc cleanups in neshawk boards, mostly removing redundant else's

This commit is contained in:
adelikat 2020-12-20 13:12:46 -06:00
parent 374f646f75
commit 2b5d0b6219
165 changed files with 772 additions and 1487 deletions

View File

@ -412,6 +412,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=Mednafen_0027s/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Memset/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=minipsf/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=mirr/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Missle/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=mmsys/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=MOTW/@EntryIndexedValue">True</s:Boolean>
@ -448,6 +449,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=otepad/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=outrate/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Overdump/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=overdumped/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Overscan/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=palettized/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Palletize/@EntryIndexedValue">True</s:Boolean>

View File

@ -51,7 +51,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
addr = (bank_4k << 12) | ofs;
return Vrom[addr];
}
else return base.ReadPpu(addr);
return base.ReadPpu(addr);
}
public override byte ReadPrg(int addr)
@ -82,7 +83,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
break;
}
}
}
// according to the latest on nesdev:
@ -127,7 +127,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
return false;
AssertPrg(32, 64); AssertChr(32, 64); AssertWram(0); AssertVram(0);
break;
default:
return false;
}
@ -192,8 +191,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
addr |= ((chr_bank_8k & chr_bank_mask_8k) << 13);
return Vrom[addr];
}
else
return base.ReadPpu(addr);
return base.ReadPpu(addr);
}
}

View File

@ -52,7 +52,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
AssertPrg(256); AssertChr(0); AssertVram(8); AssertWram(0);
bus_conflict = true; // not enough chips on the pcb to disable bus conflicts?
break;
default:
return false;
}

View File

@ -29,7 +29,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
I have no idea what [6] does.
Every real instance of [1], [2], [3], [4] had 128K or 256K of each of chr and prg.
*/
internal sealed class BANDAI_FCG_1 : NesBoardBase
{
//configuration
@ -41,10 +40,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
private bool vram = false; // is this a VRAM board? (also set to true for JUMP2)
private byte jump2_outer_bank; // needed to select between banks in 512K jump2 board
//regenerable state
// regenerable state
private readonly int[] prg_banks_16k = new int[2];
//state
// state
private int prg_reg_16k;
private byte[] regs = new byte[8];
private bool irq_enabled;
@ -162,7 +161,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
prg_bank_mask_16k = (Cart.PrgSize / 16) - 1;
// for Jump2 boards, we only mask up to 256K, the outer bank is determined seperately
// for Jump2 boards, we only mask up to 256K, the outer bank is determined separately
if (jump2)
prg_bank_mask_16k = 256 / 16 - 1;
@ -232,7 +231,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
irq_enabled = value.Bit(0);
if (jump2)
irq_counter = irq_latch;
// all write acknolwedge
// all write acknowledge
IrqSignal = false;
break;
case 0xB:
@ -346,7 +345,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
reader?.Clock();
}
public override byte ReadPrg(int addr)
{
int bank_16k = addr >> 14;
@ -371,10 +369,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
if (addr < 0x2000)
{
if (vram)
return Vram[addr];
else
return Vrom[CalcPPUAddress(addr)];
return vram ? Vram[addr] : Vrom[CalcPPUAddress(addr)];
}
return base.ReadPpu(addr);

View File

@ -57,27 +57,19 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return Vram[(0x1000 * 3 * 2) + addr];
}
else
{
return Vram[(0x1000 * 3) + addr];
}
return Vram[(0x1000 * 3) + addr];
}
else
if (chr_block == 1)
{
if (chr_block == 1)
{
return Vram[(0x1000 * chr_pos * 2) + addr];
}
else
{
return Vram[(0x1000 * chr_pos * 2) + addr];
}
return Vram[(0x1000 * chr_pos * 2) + addr];
}
return Vram[(0x1000 * chr_pos * 2) + addr];
}
else
{
return base.ReadPpu(addr);
}
return base.ReadPpu(addr);
}
public override void WritePpu(int addr, byte value)
@ -114,10 +106,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public override void AddressPpu(int addr)
{
byte newpos;
if ((addr & 0x3000) != 0x2000) return;
if ((addr & 0x3FF) >= 0x3C0) return;
newpos = (byte)((addr >> 8) & 3);
var newpos = (byte)((addr >> 8) & 3);
if (chr_pos != newpos)
{
chr_pos = newpos;

View File

@ -2,16 +2,15 @@
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
// Mapper 70
// Example Games:
// --------------------------
// Family Trainer - Manhattan Police
// Family Trainer - Meiro Daisakusen
// Kamen Rider Club
// Space Shadow
internal sealed class BANDAI_74_161_161_32 : NesBoardBase
{
//Mapper 70
//Example Games:
//--------------------------
//Family Trainer - Manhattan Police
//Family Trainer - Meiro Daisakusen
//Kamen Rider Club
//Space Shadow
private int chr;
private int prg_bank_mask_16k;
private byte prg_bank_16k;
@ -69,8 +68,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
if (addr < 0x2000)
return Vrom[(addr & 0x1FFF) + (chr * 0x2000)];
else
return base.ReadPpu(addr);
return base.ReadPpu(addr);
}
}
}

View File

@ -5,8 +5,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
// Bonza (R)
// Bonza is some kind of gambling game requiring an outside interface of some kind
// this is not implemented
// Magic Jewelry 2 (Unl)
internal sealed class Bonza : NesBoardBase
{

View File

@ -49,7 +49,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public override byte ReadPrg(int addr)
{
addr |= (prg_bank_32k << 15);
addr |= prg_bank_32k << 15;
return Rom[addr];
}
@ -68,16 +68,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return Vram[addr];
}
else
{
return Vrom[addr | (chr_bank_8k << 13)];
}
}
else
{
return base.ReadPpu(addr);
}
}
return Vrom[addr | (chr_bank_8k << 13)];
}
return base.ReadPpu(addr);
}
}
}

View File

@ -10,7 +10,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
//Arkista's Ring
//Bump 'n' Jump
//Cybernoid
[NesBoardImplPriority]
internal sealed class CNROM : NesBoardBase
{
@ -141,14 +140,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return 0x12;
}
if (addr < 0x2000)
{
return Vrom[addr + (chr << 13)];
}
else
{
return base.ReadPpu(addr);
}
return base.ReadPpu(addr);
}
public override void SyncState(Serializer ser)

View File

@ -20,18 +20,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
Cart.VramSize = 16;
Cart.WramSize = 0;
break;
case "NES-CPROM": //videomation
AssertPrg(32); AssertChr(0); AssertVram(16); AssertWram(0);
break;
default:
return false;
}
//TODO - assert that mirror type is vertical?
//set it in the cart?
SetMirrorType(EMirrorType.Vertical);
return true;
@ -47,9 +44,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
if (addr < 0x1000)
return Vram[addr];
else if(addr<0x2000)
if(addr < 0x2000)
return Vram[addr - 0x1000 + (chr << 12)];
else return base.ReadPpu(addr);
return base.ReadPpu(addr);
}
public override void WritePpu(int addr, byte value)

View File

@ -75,7 +75,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
}
}
public override byte ReadPrg(int addr)
{
int bank_16k = addr >> 14;
@ -86,7 +85,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
}
}
//AKA mapper 232
// AKA mapper 232
internal class Camerica_Mapper232 : NesBoardBase
{
//configuration
@ -124,7 +123,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
SetMirrorType(Cart.PadH, Cart.PadV);
SyncPRG();
return true;
}
@ -161,5 +159,4 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
return Rom[addr];
}
}
}

View File

@ -53,10 +53,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return Rom[((regs[0]) << 14) + (addr & 0x3FFF)];
}
else
{
return Rom[((regs[1]) << 14) + (addr & 0x3FFF)];
}
return Rom[((regs[1]) << 14) + (addr & 0x3FFF)];
}
}
}

View File

@ -134,7 +134,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
bank &= 0xFF;
return Vrom[(bank << 10) + (addr & 0x3FF)];
}
}
return base.ReadPpu(addr);
@ -188,10 +187,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
if (addr == 0x1000)
return (byte)((NES.DB & 0xFC) | 0);
else if (addr >= 0x1100 && addr <= 0x1103)
if (addr >= 0x1100 && addr <= 0x1103)
return _low[addr & 0x3];
else
return base.ReadExp(addr);
return base.ReadExp(addr);
}
}
@ -218,9 +216,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
prg_bank_mask_16k = Cart.PrgSize / 16 - 1;
prg_bank_mask_8k = Cart.PrgSize / 8 - 1;
chr_bank_mask_2k = Cart.PrgSize / 2 - 1;
//prg_regs[1] = (byte)prg_bank_mask_16k;
//is_2k_bank = true;
return true;
}
return false;
@ -313,14 +308,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
bank = chr_regs[7];
return Vrom[(bank << 11) + (addr & 0x7FF)];
} else
}
else
{
int index = (addr >> 10) & 0x7;
int bank = chr_regs[index];
bank |= ((bank & 0x30) << 4);
return Vrom[(bank << 10) + (addr & 0x3FF)];
}
}
return base.ReadPpu(addr);
@ -336,7 +331,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
}
return Rom[(((bank & 0x30) | 0xF) << 14) + (addr & 0x3FFF)];
} else
}
else
{
int index = (addr >> 13) & 0x3;
int bank = prg_regs[index];
@ -346,10 +342,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
bank = prg_bank_mask_8k;
return Rom[(bank << 13) + (addr & 0x1FFF)];
}
}
public override void ClockCpu()
@ -378,11 +371,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
if (addr == 0x1000)
return (byte)((NES.DB & 0xFC) | 0);
else if (addr >= 0x1100 && addr <= 0x1103)
if (addr >= 0x1100 && addr <= 0x1103)
return _low[addr & 0x3];
else
return base.ReadExp(addr);
return base.ReadExp(addr);
}
}
@ -409,7 +400,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
if (Cart.PrgSize == 1024)
{
prg_bank_mask_16k = Cart.PrgSize / 16 - 1;
prg_regs[1] = (byte)prg_bank_mask_16k;
return true;
}

View File

@ -4,13 +4,11 @@ using BizHawk.Common.NumberExtensions;
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
// eldritch horror pirate multicart
// 32MB prg rom, no prg ram, no chr rom, 128KB chr ram
// behavior directly from fceu-mm
internal sealed class CoolBoy : MMC3Board_Base
{
// eldritch horror pirate multicart
// 32MB prg rom, no prg ram, no chr rom, 128KB chr ram
// behavior directly from fceu-mm
// this could be broken down into more sensibly named variables
private byte[] exp = new byte[4];
@ -45,16 +43,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
if (!exp[3].Bit(7))
{
exp[addr & 3] = value;
/*
if (exp[3].Bit(7))
{
Console.WriteLine("EXP Write Protect Activated");
}
if (exp[3].Bit(4))
{
Console.WriteLine("Funky Mode Active");
}
*/
}
}
}
@ -62,17 +50,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
protected override int Get_PRGBank_8K(int addr)
{
int mask = 0, shift = 0;
int baseaddr = exp[0] & 0x07 | (exp[1] & 0x10) >> 1 | (exp[1] & 0x0c) << 2 | (exp[0] & 0x30) << 2;
int baseAddr = exp[0] & 0x07 | (exp[1] & 0x10) >> 1 | (exp[1] & 0x0c) << 2 | (exp[0] & 0x30) << 2;
switch (exp[0] & 0xc0)
{
case 0x00:
baseaddr >>= 2;
baseAddr >>= 2;
mask = 0x3f;
shift = 6;
break;
case 0x80:
baseaddr >>= 1;
baseAddr >>= 1;
mask = 0x1f;
shift = 5;
break;
@ -94,7 +82,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
int v = base.Get_PRGBank_8K(addr);
int ret = baseaddr << shift | v & mask;
int ret = baseAddr << shift | v & mask;
if (exp[3].Bit(4))
{
ret |= exp[3] & (0x0e ^ exp[1] & 2);
@ -108,10 +96,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return (exp[2] & 15) << 3 | addr >> 10 & 7;
}
else
{
return base.Get_CHRBank_1K(addr);
}
return base.Get_CHRBank_1K(addr);
}
public override void SyncState(Serializer ser)

View File

@ -7,7 +7,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
// mostly jacked from nestopia's NstBoardBandaiDatach.cpp
// very dirty, needs cleanup and such
public class DatachBarcode : IEmulatorService
{
private static readonly byte[,] prefixParityType = new byte[10, 6]
@ -67,7 +66,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
ser.EndSection();
}
public void Reset()
{
cycles = 0;
@ -79,10 +77,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return stream_idx < data.Length;
}
private static bool IsDigtsSupported(int count)
{
return count.In(MIN_DIGITS, MAX_DIGITS);
}
public static bool ValidString(string s, out string why)
{
@ -178,7 +172,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
for (int j = 0; j < 7; j++)
result.WriteByte(dataRight[code[i], j]);
for (int i = 0; i < 7; i++)
sum += code[i] * ((i & 1) != 0 ? 3 : 1);
}

View File

@ -123,7 +123,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
else
chr_bank_mask_1k = Cart.VramSize - 1;
PoweronState();
PowerOnState();
if (NES.apu != null)
audio = new MMC5Audio(NES.apu.ExternalQueue, e => { irq_audio = e; SyncIRQ(); });
@ -131,9 +131,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
return true;
}
private void PoweronState()
private void PowerOnState()
{
//set all prg regs to use ROM
// set all prg regs to use ROM
regs_prg[0] = 0x80;
regs_prg[1] = 0x80;
regs_prg[2] = 0x80;
@ -265,7 +265,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
}
bank_1k &= chr_bank_mask_1k;
addr = (bank_1k<<10)|ofs;
addr = (bank_1k << 10) | ofs;
return addr;
}
@ -517,7 +517,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
nt_fill_attrib |= (byte)(nt_fill_attrib << 2);
nt_fill_attrib |= (byte)(nt_fill_attrib << 4);
break;
case 0x1113: //$5113: [.... .PPP] (simplified, but technically inaccurate -- see below)
wram_bank = value & 7;
@ -701,7 +700,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
SyncIRQ();
}
}
}
public override void ClockCpu()

View File

@ -80,7 +80,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
_irqCount |= value << 8;
_irqEnable = true;
break;
}
SyncIRQ();

View File

@ -3,7 +3,6 @@
internal sealed class FS304 : NesBoardBase
{
// waixing?
private int prg;
private int prg_mask_32k;

View File

@ -1,9 +1,8 @@
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
// http://forums.nesdev.com/viewtopic.php?f=9&t=11099
internal sealed class Farid_UNROM_8_in_1 : NesBoardBase
{
// http://forums.nesdev.com/viewtopic.php?f=9&t=11099
// state
private int c; // clock bit for the second 74'161
private int e; // /load for second 74'161. guaranteed to be 0 on powerup

View File

@ -3,7 +3,6 @@
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
// this is an internal testing thing, not really for using
internal sealed class GameGenie : NesBoardBase
{
private static readonly byte[] PatternTables = new byte[256];
@ -53,16 +52,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
if (addr < 0x4000)
return NES.DB;
else
return Rom[addr & 0xfff];
return Rom[addr & 0xfff];
}
public override byte ReadPpu(int addr)
{
if (addr >= 0x2000)
return base.ReadPpu(addr);
else
return PatternTables[addr & 0xff];
return PatternTables[addr & 0xff];
}
public override void WritePrg(int addr, byte value)

View File

@ -52,7 +52,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
if(origin == EDetectionOrigin.INES)
Console.WriteLine("Caution! This board (inferred from iNES) might have wrong mirr.type");
return true;
}
public override byte ReadPrg(int addr)
@ -66,13 +65,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return Vrom[addr + (chr << 13)];
}
else return base.ReadPpu(addr);
return base.ReadPpu(addr);
}
public override void WritePrg(int addr, byte value)
{
chr = ((value & 7) & chr_mask);
prg = (((value>>4) & 3) & prg_mask);
chr = (value & 7) & chr_mask;
prg = ((value>>4) & 3) & prg_mask;
}
public override void SyncState(Serializer ser)

View File

@ -3,11 +3,9 @@ using BizHawk.Common;
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
//mapper 011
//Crystal Mines
//Metal Fighter
// Mapper 011
// Crystal Mines
// Metal Fighter
[NesBoardImplPriority]
internal sealed class IC_74x377 : NesBoardBase
{
@ -64,7 +62,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return Vrom[addr + (chr_bank_8k << 13)];
}
else return base.ReadPpu(addr);
return base.ReadPpu(addr);
}
public override void WritePrg(int addr, byte value)

View File

@ -2,17 +2,15 @@
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
//Mapper 77
//Napoleon Senki
//the 4screen implementation is a bit of a guess, but it seems to work
// https://wiki.nesdev.com/w/index.php/INES_Mapper_077
// Napoleon Senki
// the 4screen implementation is a bit of a guess, but it seems to work
internal sealed class IREM_74_161_161_21_138 : NesBoardBase
{
private int chr, prg;
public override bool Configure(EDetectionOrigin origin)
{
//configure
// configure
switch (Cart.BoardType)
{
case "MAPPER077":
@ -46,18 +44,18 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
if (addr < 0x0800)
return Vrom[addr + (chr * 0x0800)];
else if (addr < 0x2000)
if (addr < 0x2000)
return Vram[addr];
else if (addr < 0x2800)
if (addr < 0x2800)
return Vram[addr & 0x7ff];
else return base.ReadPpu(addr);
return base.ReadPpu(addr);
}
public override void WritePpu(int addr, byte value)
{
if (addr < 0x0800)
return;
else if (addr < 0x2000)
if (addr < 0x2000)
Vram[addr] = value;
else if (addr < 0x2800)
Vram[addr & 0x7ff] = value;
@ -68,8 +66,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
if (addr < 0x8000)
return Rom[addr + (prg * 0x8000)];
else
return base.ReadPrg(addr);
return base.ReadPrg(addr);
}
}
}

View File

@ -2,9 +2,8 @@
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
//iNES Mapper 97
//Kaiketsu Yanchamaru (Kid Niki 1)
// https://wiki.nesdev.com/w/index.php/INES_Mapper_097
// Kaiketsu Yanchamaru (Kid Niki 1)
internal sealed class IREM_TAM_S1 : NesBoardBase
{
private int prg_bank_mask_16k;

View File

@ -2,12 +2,10 @@
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
//AKA mapper 032
//Image Fight
//Major League
//Kaiketsu Yanchamaru 2
//AKA Mapper 032
// Image Fight
// Major League
// Kaiketsu Yanchamaru 2
internal sealed class Irem_G101 : NesBoardBase
{
//configuration
@ -68,10 +66,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
if (oneScreenHack)
SetMirrorType(EMirrorType.OneScreenA);
else
if (mirror_mode == 0)
SetMirrorType(EMirrorType.Vertical);
else SetMirrorType(EMirrorType.Horizontal);
else if (mirror_mode == 0)
SetMirrorType(EMirrorType.Vertical);
else SetMirrorType(EMirrorType.Horizontal);
}
public override void WritePrg(int addr, byte value)
@ -123,8 +120,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
addr = (bank_1k << 10) | ofs;
return Vrom[addr];
}
else
return base.ReadPpu(addr);
return base.ReadPpu(addr);
}
public override byte ReadPrg(int addr)

View File

@ -2,13 +2,10 @@
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
//AKA mapper 65
//Daiku no Gen San 2
//Spartan X 2
//NOTE - fceux support for this mapper has some kind of -4 cpu cycle delay built into the timer. not sure yet whether we need that
//AKA Mapper 65
// Daiku no Gen San 2
// Spartan X 2
// NOTE - fceux support for this mapper has some kind of -4 cpu cycle delay built into the timer. not sure yet whether we need that
internal sealed class Irem_H3001 : NesBoardBase
{
//configuration
@ -58,17 +55,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
return true;
}
/*
public override void ClockPPU()
{
clock_counter++;
if (clock_counter == 3)
{
ClockCPU();
clock_counter = 0;
}
}*/
public override void ClockCpu()
{
if (irq_counter == 0) return;
@ -105,8 +91,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
addr = (bank_1k << 10) | ofs;
return Vrom[addr];
}
else
return base.ReadPpu(addr);
return base.ReadPpu(addr);
}
public override void WritePrg(int addr, byte value)

View File

@ -67,8 +67,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
if (addr < 0x2000)
return Vrom[addr | chr << 13];
else
return base.ReadPpu(addr);
return base.ReadPpu(addr);
}
public override byte ReadPrg(int addr)

View File

@ -2,13 +2,11 @@
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
//Mapper 86
//Example Games:
//--------------------------
//Moero!! Pro Yakyuu (Black)
//Moero!! Pro Yakyuu (Red)
// Mapper 86
// Example Games:
// --------------------------
// Moero!! Pro Yakyuu (Black)
// Moero!! Pro Yakyuu (Red)
internal sealed class JALECO_JF_13 : NesBoardBase
{
//configuration
@ -43,16 +41,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
if (addr < 0x8000)
return Rom[addr + (prg * 0x8000)];
else
return base.ReadPrg(addr);
return base.ReadPrg(addr);
}
public override byte ReadPpu(int addr)
{
if (addr < 0x2000)
return Vrom[(addr & 0x1FFF) + (chr * 0x2000)];
else
return base.ReadPpu(addr);
return base.ReadPpu(addr);
}
public override void WriteWram(int addr, byte value)

View File

@ -2,19 +2,18 @@
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
//iNES Mapper 72
//Example Games:
//--------------------------
//Pinball Quest (J)
//Moero!! Pro Tennis
//Moero!! Juudou Warriors
//based on the chips on the pcb (3x 4bit registers and some OR gates) i'm gonna speculate something a little different about how this works.
//there isnt enough memory for 2 bank registers, a latched bank, and a latched command. so i think the bank isnt latched--the command is latched.
//when the top 2 bits are 0, then the low 4 bits are written to the register specified by the latch
//when the top 2 bits arent 0, theyre written to the latch
//interestingly, this works (for pinball quest) only when bus conflicts are applied, otherwise the game cant get past the title
// iNES Mapper 72
// Example Games:
// --------------------------
// Pinball Quest (J)
// Moero!! Pro Tennis
// Moero!! Juudou Warriors
// based on the chips on the pcb (3x 4bit registers and some OR gates) i'm gonna speculate something a little different about how this works.
// there isnt enough memory for 2 bank registers, a latched bank, and a latched command. so i think the bank isnt latched--the command is latched.
// when the top 2 bits are 0, then the low 4 bits are written to the register specified by the latch
// when the top 2 bits arent 0, theyre written to the latch
// interestingly, this works (for pinball quest) only when bus conflicts are applied, otherwise the game cant get past the title
internal sealed class JALECO_JF_17 : NesBoardBase
{
//configuration
@ -66,8 +65,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public override void WritePrg(int addr, byte value)
{
//Console.WriteLine("MAP {0:X4} = {1:X2}", addr, value);
value = HandleNormalPRGConflict(addr, value);
int command = value >> 6;
@ -97,9 +94,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
if (addr < 0x2000)
{
addr = ApplyMemoryMap(13, chr_banks_8k, addr);
return base.ReadPPUChr(addr);
return ReadPPUChr(addr);
}
else return base.ReadPpu(addr);
return base.ReadPpu(addr);
}
}
}

View File

@ -3,15 +3,13 @@ using BizHawk.Common.NumberExtensions;
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
//iNES Mapper 92
//Example Games:
//Example Games:
//--------------------------
//Moero!! Pro Soccer
//Moero!! Pro Yakyuu '88 - Ketteiban
//Near Identical to Jaleco JF 17, except for a slight PRG setup
// iNES Mapper 92
// Example Games:
// Example Games:
// --------------------------
// Moero!! Pro Soccer
// Moero!! Pro Yakyuu '88 - Ketteiban
// Near Identical to Jaleco JF 17, except for a slight PRG setup
internal sealed class JALECO_JF_19 : NesBoardBase
{
//configuration
@ -63,25 +61,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public override void WritePrg(int addr, byte value)
{
//Console.WriteLine("MAP {0:X4} = {1:X2}", addr, value);
value = HandleNormalPRGConflict(addr, value);
/*
int command = value >> 6;
switch (command)
{
case 0:
if (latch == 1)
chr_banks_8k[0] = (byte)(value & 0xF);
else if (latch == 2)
prg_banks_16k[1] = (byte)(value & 0xF);
SyncMap();
break;
default:
latch = command;
break;
}
*/
// the important change here is that the chr and prg bank latches get filled on the rising edge, not falling
if (value.Bit(6) && !latch.Bit(6))
@ -103,9 +83,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
if (addr < 0x2000)
{
addr = ApplyMemoryMap(13, chr_banks_8k, addr);
return base.ReadPPUChr(addr);
return ReadPPUChr(addr);
}
else return base.ReadPpu(addr);
return base.ReadPpu(addr);
}
}
}

View File

@ -2,10 +2,9 @@
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
// http://wiki.nesdev.com/w/index.php/INES_Mapper_018
internal sealed class JALECO_SS8806 : NesBoardBase
{
//http://wiki.nesdev.com/w/index.php/INES_Mapper_018
private byte[] prg_banks_8k = new byte[4];
private byte[] chr_banks_1k = new byte[8];
private int chr_bank_mask_1k, prg_bank_mask_8k;
@ -15,7 +14,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
private int irqcountwidth;
private bool irqcountpaused;
public override bool Configure(EDetectionOrigin origin)
{
//analyze board type
@ -207,13 +205,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
else
irqcountwidth = 16;
break;
case 0xF003:
// sound chip µPD7756C
break;
}
}
public override void ClockCpu()
@ -221,7 +216,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
if (!irqcountpaused)
{
int newclock = irqclock - 1;
if (squeeze(newclock) > squeeze(irqclock))
if (Squeeze(newclock) > Squeeze(irqclock))
{
IrqSignal = true;
irqclock = irqreload;
@ -234,7 +229,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
/// <summary>
/// emulate underflow for the appropriate number of bits
/// </summary>
private uint squeeze(int input)
private uint Squeeze(int input)
{
unchecked
{
@ -269,9 +264,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
addr = MapCHR(addr);
if (Vrom != null)
return Vrom[addr];
else return Vram[addr];
return Vram[addr];
}
else return base.ReadPpu(addr);
return base.ReadPpu(addr);
}
}
}

View File

@ -3,24 +3,22 @@
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
/*
* Life Span: October 1986 - April 1987
PCB Class: Jaleco-JF-11
Jaleco-JF-14
iNES Mapper 140
JF-11
PRG-ROM: 128kb
CHR-ROM: 32kb
Battery is not available
Uses vertical mirroring
No CIC present
Other chips used: Sunsoft-1
*
* Games:
* Mississippi Satsujin Jiken (J)
* Bio Senshi Dan - Increaser Tono Tatakai [allegedly; but it does not work]
*/
Life Span: October 1986 - April 1987
PCB Class: Jaleco-JF-11
Jaleco-JF-14
iNES Mapper 140
JF-11
PRG-ROM: 128kb
CHR-ROM: 32kb
Battery is not available
Uses vertical mirroring
No CIC present
Other chips used: Sunsoft-1
Games:
Mississippi Satsujin Jiken (J)
Bio Senshi Dan - Increaser Tono Tatakai [allegedly; but it does not work]
*/
internal sealed class Jaleco_JF_11_14 : NesBoardBase
{
private int chr, prg;
@ -47,16 +45,14 @@ Other chips used: Sunsoft-1
{
if (addr < 0x8000)
return Rom[addr + (prg * 0x8000)];
else
return base.ReadPrg(addr);
return base.ReadPrg(addr);
}
public override byte ReadPpu(int addr)
{
if (addr < 0x2000)
return Vrom[(addr & 0x1FFF) + (chr * 0x2000)];
else
return base.ReadPpu(addr);
return base.ReadPpu(addr);
}
public override void WriteWram(int addr, byte value)

View File

@ -72,27 +72,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return eRAM[(addr & 0x07)];
}
else
{
return base.ReadExp(addr);
}
return base.ReadExp(addr);
}
public override void WritePrg(int addr, byte value)
{
//$8000-FFFF: [.... ..CC] Low 2 bits of CHR
//A~[..MH HPPP PPO. CCCC]
// $8000-FFFF: [.... ..CC] Low 2 bits of CHR
// A~[..MH HPPP PPO. CCCC]
addr += 0x8000;
if (addr.Bit(13))
{
SetMirrorType(EMirrorType.Horizontal);
}
else
{
SetMirrorType(EMirrorType.Vertical);
}
SetMirrorType(addr.Bit(13) ? EMirrorType.Horizontal : EMirrorType.Vertical);
prg_mode = addr.Bit(5);
prg_reg = (addr >> 6) & 0x1F;
@ -133,10 +123,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
int bank = (prg_reg >> 1) & prg_bank_mask_32k;
return Rom[(bank * 0x8000) + addr + chip_offset];
}
else
{
return Rom[((prg_reg & prg_bank_mask_16k) * 0x4000) + (addr & 0x3FFF) + chip_offset];
}
return Rom[((prg_reg & prg_bank_mask_16k) * 0x4000) + (addr & 0x3FFF) + chip_offset];
}
}
}

View File

@ -3,10 +3,9 @@ using BizHawk.Common.NumberExtensions;
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
// http://wiki.nesdev.com/w/index.php/INES_Mapper_234
internal sealed class MLT_MAX15 : NesBoardBase
{
//http://wiki.nesdev.com/w/index.php/INES_Mapper_234
private bool mode = false;
private int block_high = 0;
private int block_low = 0;
@ -126,7 +125,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
}
return value;
}
public override byte ReadPpu(int addr)

View File

@ -7,8 +7,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
//for simplicity's sake, the behaviour of mmc6 is wrapped up into this board since it isnt used anywhere else
internal sealed class HKROM : MMC3Board_Base
{
//configuration
//state
private bool wram_enabled;
private bool wram_h_enabled, wram_l_enabled;
@ -113,6 +111,5 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
return base.ReadWram(addr);
return 0;
}
}
}

View File

@ -300,7 +300,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
a12_old = a12;
}
}
}
@ -310,7 +309,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public MMC3 mmc3;
public int extra_vrom;
public override void AddressPpu(int addr)
{
mmc3.AddressPPU(addr);
@ -355,9 +353,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
if (addr < 0x2000)
{
addr = MapCHR(addr);
if (Vrom != null)
return Vrom[addr + extra_vrom];
else return Vram[addr];
return Vrom?[addr + extra_vrom] ?? Vram[addr];
}
return base.ReadPpu(addr);

View File

@ -45,6 +45,5 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
else bank_1k += (block1 << 8);
return bank_1k;
}
}
}

View File

@ -44,7 +44,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
base.WriteWram(addr, value);
}
protected override int Get_PRGBank_8K(int addr)
{
if (mode)

View File

@ -2,13 +2,11 @@
//27
//TODO - could merge functionality with 192 somehow
//http://wiki.nesdev.com/w/index.php/INES_Mapper_074
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
internal sealed class Mapper074 : MMC3Board_Base
{
//http://wiki.nesdev.com/w/index.php/INES_Mapper_074
public override bool Configure(EDetectionOrigin origin)
{
//analyze board type

View File

@ -55,23 +55,22 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
int bank_8k = mmc3.Get_PRGBank_8K(addr);
if (prg_mode_mapper == false) return bank_8k;
else if (addr < 0x2000)
if (addr < 0x2000)
{
return prg_page*4;
}
else if (addr < 0x4000)
if (addr < 0x4000)
{
return prg_page*4 + 1;
}
else if (addr < 0x6000)
if (addr < 0x6000)
{
return prg_page*4 + 2;
}
else
{
return prg_page*4 + 3;
}
return prg_page*4 + 3;
}
protected override int Get_CHRBank_1K(int addr)

View File

@ -35,10 +35,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return exRegs[2];
}
else
{
return base.ReadExp(addr);
}
return base.ReadExp(addr);
}
public override void WriteExp(int addr, byte value)

View File

@ -77,16 +77,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return Rom[((bank >> 1) << 15) + (addr & 0x7FFF)];
}
else
{
return Rom[(bank << 14) + (addr & 0x3FFF)];
}
}
else
{
//return (byte)(base.ReadPRG(addr) & 0x3F);
return base.ReadPrg(addr);
return Rom[(bank << 14) + (addr & 0x3FFF)];
}
//return (byte)(base.ReadPRG(addr) & 0x3F);
return base.ReadPrg(addr);
}
}
}

View File

@ -26,7 +26,7 @@
case 0x8000: break; //?
case 0x8001: base.WritePrg(0xA000,value); break;
case 0xA000:
value = (byte)scramble_A000(value);
value = (byte)ScrambleA000(value);
base.WritePrg(0x8000,value);
break;
case 0xA001: break; //?
@ -43,7 +43,7 @@
private static readonly byte[] scramble_table = { 0, 3, 1, 5, 6, 7, 2, 4 };
private static int scramble_A000(byte val)
private static int ScrambleA000(byte val)
{
return (val & ~0x7) | scramble_table[val & 0x7];
}

View File

@ -48,6 +48,5 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
WriteWram(addr, value);
}
}
}

View File

@ -38,7 +38,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
//this is referencing chr ram
return Vram[addr & 0x7FF];
}
else return base.ReadPpu(addr);
return base.ReadPpu(addr);
}
public override void WritePpu(int addr, byte value)
@ -57,6 +58,5 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
}
else base.WritePpu(addr, value);
}
}
}

View File

@ -1,9 +1,8 @@
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
// http://wiki.nesdev.com/w/index.php/INES_Mapper_192
internal sealed class Mapper192 : MMC3Board_Base
{
//http://wiki.nesdev.com/w/index.php/INES_Mapper_192
public override bool Configure(EDetectionOrigin origin)
{
//analyze board type
@ -47,7 +46,6 @@
}
}
public override byte ReadPpu(int addr)
{
if (addr < 0x2000)
@ -58,26 +56,28 @@
byte value = Vram[addr & 0x03FF];
return value;
}
else if (bank == 0x09)
if (bank == 0x09)
{
return Vram[(addr & 0x03FF) + 0x400];
}
else if (bank == 0x0A)
if (bank == 0x0A)
{
return Vram[(addr & 0x03FF) + 0x800];
}
else if (bank == 0x0B)
if (bank == 0x0B)
{
return Vram[(addr & 0x03FF) + 0xC00];
}
else
{
addr = MapCHR(addr);
return Vrom[addr + extra_vrom];
}
addr = MapCHR(addr);
return Vrom[addr + extra_vrom];
}
else return base.ReadPpu(addr);
return base.ReadPpu(addr);
}
}
}

View File

@ -1,9 +1,8 @@
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
// http://wiki.nesdev.com/w/index.php/INES_Mapper_194
internal sealed class Mapper194 : MMC3Board_Base
{
//http://wiki.nesdev.com/w/index.php/INES_Mapper_194
public override bool Configure(EDetectionOrigin origin)
{
//analyze board type
@ -47,18 +46,18 @@
{
return Vram[addr & 0x03FF];
}
else if (bank == 0x01)
if (bank == 0x01)
{
return Vram[(addr & 0x03FF) + 0x400];
}
else
{
addr = MapCHR(addr);
return Vrom[addr + extra_vrom];
}
addr = MapCHR(addr);
return Vrom[addr + extra_vrom];
}
else return base.ReadPpu(addr);
return base.ReadPpu(addr);
}
}
}

View File

@ -62,14 +62,12 @@
{
return Vram[(bank_1k << 10) + (addr & 0x3FF)];
}
else
{
addr = MapCHR(addr);
return Vrom[addr + extra_vrom];
}
addr = MapCHR(addr);
return Vrom[addr + extra_vrom];
}
else
return base.ReadPpu(addr);
return base.ReadPpu(addr);
}
public override void WritePpu(int addr, byte value)

View File

@ -41,14 +41,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return Vram[(bank_1k << 10) + (addr & 0x3FF)];
}
else
{
addr = MapCHR(addr);
return Vrom[addr + extra_vrom];
}
addr = MapCHR(addr);
return Vrom[addr + extra_vrom];
}
else
return base.ReadPpu(addr);
return base.ReadPpu(addr);
}
public override void WritePpu(int addr, byte value)

View File

@ -74,11 +74,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return Rom[addr | prgreg << 15];
}
else
{
return base.ReadPrg(addr);
}
}
return base.ReadPrg(addr);
}
}
}

View File

@ -53,7 +53,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
chr_regs_1k_512[4 | i] = chr_right_upper | i;
chr_regs_1k_512[6 | i] = chr_right_lower | i;
}
}
public override void SyncState(Serializer ser)

View File

@ -43,60 +43,49 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
if (mmc3.regs[0]<8)
{
return Vram[(mmc3.regs[0] << 10) + (addr & 0x3FF)];
} else
{
return Vrom[(mmc3.regs[0] << 10) + (addr & 0x3FF)];
}
return Vrom[(mmc3.regs[0] << 10) + (addr & 0x3FF)];
}
else if (addr<0x800)
if (addr<0x800)
{
if (exRegs[2] < 8)
{
return Vram[(exRegs[2] << 10) + (addr & 0x3FF)];
}
else
{
return Vrom[(exRegs[2] << 10) + (addr & 0x3FF)];
}
return Vrom[(exRegs[2] << 10) + (addr & 0x3FF)];
}
else if (addr < 0xC00)
if (addr < 0xC00)
{
if (mmc3.regs[1] < 8)
{
return Vram[(mmc3.regs[1] << 10) + (addr & 0x3FF)];
}
else
{
return Vrom[(mmc3.regs[1] << 10) + (addr & 0x3FF)];
}
return Vrom[(mmc3.regs[1] << 10) + (addr & 0x3FF)];
}
else
if (exRegs[3] < 8)
{
if (exRegs[3] < 8)
{
return Vram[(exRegs[3] << 10) + (addr & 0x3FF)];
}
else
{
return Vrom[(exRegs[3] << 10) + (addr & 0x3FF)];
}
return Vram[(exRegs[3] << 10) + (addr & 0x3FF)];
}
return Vrom[(exRegs[3] << 10) + (addr & 0x3FF)];
}
else
int bank_1k = Get_CHRBank_1K(addr);
if (bank_1k < 8)
{
int bank_1k = Get_CHRBank_1K(addr);
if (bank_1k < 8)
{
return Vram[(bank_1k << 10) + (addr & 0x3FF)];
}
else
{
return Vrom[(bank_1k << 10) + (addr & 0x3FF)];
}
return Vram[(bank_1k << 10) + (addr & 0x3FF)];
}
return Vrom[(bank_1k << 10) + (addr & 0x3FF)];
}
else
return base.ReadPpu(addr);
return base.ReadPpu(addr);
}
public override void WritePpu(int addr, byte value)
@ -173,7 +162,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return exRegs[0];
}
else if (addr >= 0x6000)
if (addr >= 0x6000)
{
return exRegs[1];
}

View File

@ -2,10 +2,9 @@
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
// Mapper 205 info: http://wiki.nesdev.com/w/index.php/INES_Mapper_205
internal sealed class Mapper205 : MMC3Board_Base
{
//Mapper 205 info: http://wiki.nesdev.com/w/index.php/INES_Mapper_205
private int block;
public override bool Configure(EDetectionOrigin origin)
@ -97,11 +96,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
if (addr < 0x2000)
{
addr = MapCHR2(addr);
if (Vrom != null)
return Vrom[addr + extra_vrom];
else return Vram[addr];
return Vrom?[addr + extra_vrom] ?? Vram[addr];
}
else return base.ReadPpu(addr);
return base.ReadPpu(addr);
}
public override void NesSoftReset()

View File

@ -79,7 +79,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
exRegs[addr & 3] = (byte)(value ^ lut[exRegs[4]]);
}
}
else
{
base.WriteExp(addr, value);

View File

@ -5,43 +5,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
internal sealed class Mapper215 : MMC3Board_Base
{
private byte[] exRegs = new byte[4];
public byte[] prg_regs_8k = new byte[4];
private bool is_mk3;
private int prg_mask_8k, chr_mask_1k;
private readonly byte[] regs_sec = { 0, 2, 5, 3, 6, 1, 7, 4 };
/*
* I'm not sure where these matrices originated from, but they don't seem to be needed
* so let's leave them as commented out in case a need arises
private readonly byte[,] regperm = new byte[,]
{
{ 0, 1, 2, 3, 4, 5, 6, 7 },
{ 0, 2, 6, 1, 7, 3, 4, 5 },
{ 0, 5, 4, 1, 7, 2, 6, 3 }, // unused
{ 0, 6, 3, 7, 5, 2, 4, 1 },
{ 0, 2, 5, 3, 6, 1, 7, 4 }, // only one actually used?
{ 0, 1, 2, 3, 4, 5, 6, 7 }, // empty
{ 0, 1, 2, 3, 4, 5, 6, 7 }, // empty
{ 0, 1, 2, 3, 4, 5, 6, 7 }, // empty
};
private readonly byte[,] adrperm = new byte[,]
{
{ 0, 1, 2, 3, 4, 5, 6, 7 },
{ 3, 2, 0, 4, 1, 5, 6, 7 },
{ 0, 1, 2, 3, 4, 5, 6, 7 }, // unused
{ 5, 0, 1, 2, 3, 7, 6, 4 },
{ 3, 1, 0, 5, 2, 4, 6, 7 }, // only one actully used?
{ 0, 1, 2, 3, 4, 5, 6, 7 }, // empty
{ 0, 1, 2, 3, 4, 5, 6, 7 }, // empty
{ 0, 1, 2, 3, 4, 5, 6, 7 }, // empty
};
*/
public override bool Configure(EDetectionOrigin origin)
{
switch (Cart.BoardType)
@ -69,7 +39,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
prg_regs_8k[2] = (byte)(0xFE & prg_mask_8k);
prg_regs_8k[3] = (byte)(0xFF & prg_mask_8k);
return true;
}
@ -87,18 +56,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
if ((exRegs[0] & 0x80) == 0)
{
int temp = 0;
//for (int i=0;i<4;i++)
//{
temp = mmc3.prg_regs_8k[i];
int temp = mmc3.prg_regs_8k[i];
if ((exRegs[1] & 0x8) > 0)
temp = (temp & 0x1F) | 0x20;
else
temp = ((temp & 0x0F) | (exRegs[1] & 0x10));
if ((exRegs[1] & 0x8) > 0)
temp = (temp & 0x1F) | 0x20;
else
temp = ((temp & 0x0F) | (exRegs[1] & 0x10));
prg_regs_8k[i] = (byte)(temp & prg_mask_8k);
//}
prg_regs_8k[i] = (byte)(temp & prg_mask_8k);
}
}
@ -196,14 +161,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
}
else
{
if (value==0)
{
SetMirrorType(EMirrorType.Vertical);
}
else
{
SetMirrorType(EMirrorType.Horizontal);
}
SetMirrorType(value == 0 ? EMirrorType.Vertical : EMirrorType.Horizontal);
}
break;
case 0xA001:
@ -211,14 +169,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
break;
case 0xC000:
if (exRegs[2]>0)
if ((value >> 7 | value) == 0)
{
SetMirrorType(EMirrorType.Vertical);
}
else
{
SetMirrorType(EMirrorType.Horizontal);
}
SetMirrorType((value >> 7 | value) == 0 ? EMirrorType.Vertical : EMirrorType.Horizontal);
else
base.WritePrg(0x4000, value);
break;
@ -260,7 +211,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
addr = (bank_1k << 10) | (addr & 0x3FF);
return Vrom[addr];
}
else return base.ReadPpu(addr);
return base.ReadPpu(addr);
}
public override byte ReadPrg(int addr)

View File

@ -10,7 +10,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
private int prg_mask_8k, chr_mask_1k;
private readonly byte[] regs_sec = { 0, 6, 3, 7, 5, 2, 4, 1 };
public override bool Configure(EDetectionOrigin origin)
{
switch (Cart.BoardType)
@ -50,17 +49,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public void sync_prg()
{
int temp = 0;
for (int i=0;i<4;i++)
{
temp = mmc3.prg_regs_8k[i];
int temp = mmc3.prg_regs_8k[i];
if ((exRegs[1] & 0x8) > 0)
temp = temp & 0x1F;
else
temp = ((temp & 0x0F) | (exRegs[1] & 0x10));
temp |= (exRegs[1] << 5 & 0x60);
temp |= (exRegs[1] << 5 & 0x60);
prg_regs_8k[i] = (byte)(temp & prg_mask_8k);
}
}
@ -144,28 +142,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
}
else
{
if (value == 0)
{
SetMirrorType(EMirrorType.Vertical);
}
else
{
SetMirrorType(EMirrorType.Horizontal);
}
SetMirrorType(value == 0 ? EMirrorType.Vertical : EMirrorType.Horizontal);
}
break;
case 0xA001:
if (exRegs[2] > 0)
{
if (value == 0)
{
SetMirrorType(EMirrorType.Vertical);
}
else
{
SetMirrorType(EMirrorType.Horizontal);
}
} else
SetMirrorType(value == 0 ? EMirrorType.Vertical : EMirrorType.Horizontal);
}
else
{
base.WritePrg(0x2001, value);
}
@ -190,9 +175,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
addr = (bank_1k << 10) | (addr & 0x3FF);
return Vrom[addr];
}
else return base.ReadPpu(addr);
}
return base.ReadPpu(addr);
}
public override byte ReadPrg(int addr)
{

View File

@ -103,7 +103,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
}
break;
}
}
}
else
base.WritePrg(addr, value);
}
@ -128,8 +128,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
}
return Vram[((bank_chr << 10) + (addr & 0x3FF))];
}
else
return base.ReadPpu(addr);
return base.ReadPpu(addr);
}
public override void WritePpu(int addr, byte value)

View File

@ -22,7 +22,7 @@
public override void WriteExp(int addr, byte value)
{
if (addr>0x1000)
if (addr > 0x1000)
{
Wram[addr + 0x4000 - (0x5000 - 0x2000)] = value;
}
@ -36,8 +36,8 @@
{
return Wram[addr + 0x4000 - (0x5000 - 0x2000)];
}
else
return base.ReadExp(addr);
return base.ReadExp(addr);
}
}
}

View File

@ -3,9 +3,9 @@ using BizHawk.Common.NumberExtensions;
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
// http://wiki.nesdev.com/w/index.php/INES_Mapper_245
internal sealed class Mapper245 : MMC3Board_Base
{
//http://wiki.nesdev.com/w/index.php/INES_Mapper_245
private bool chr_mode;
public override bool Configure(EDetectionOrigin origin)
@ -68,20 +68,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return Vram[addr + 0x1000];
}
else
{
return Vram[addr - 0x1000];
}
}
else
{
return Vram[addr];
return Vram[addr - 0x1000];
}
return Vram[addr];
}
else
{
return base.ReadPpu(addr);
}
return base.ReadPpu(addr);
}
public override void WritePpu(int addr, byte value)

View File

@ -33,10 +33,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return Wram[addr];
}
else
{
return (byte)(Wram[addr] ^ regs[1]);
}
return (byte)(Wram[addr] ^ regs[1]);
}
public override void WritePrg(int addr, byte value)

View File

@ -55,6 +55,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return (byte)block;
}
public override void WriteWram(int addr, byte value)
{
if (mmc3.wram_enable && !mmc3.wram_write_protect)
@ -62,6 +63,5 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
block = value & 1;
}
}
}
}

View File

@ -5,7 +5,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
internal sealed class MapperPocahontas : MMC3Board_Base
{
private byte[] exRegs = new byte[3];
public byte[] prg_regs_8k = new byte[4];
private int prg_mask_8k, chr_mask_1k;
@ -35,7 +34,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
prg_regs_8k[2] = (byte)(0xFE & prg_mask_8k);
prg_regs_8k[3] = (byte)(0xFF & prg_mask_8k);
return true;
}
@ -62,14 +60,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
if (addr < 0xA000)
{
if (((value >> 7) | value)==0)
{
SetMirrorType(EMirrorType.Vertical);
}
else
{
SetMirrorType(EMirrorType.Horizontal);
}
SetMirrorType(((value >> 7) | value) == 0 ? EMirrorType.Vertical : EMirrorType.Horizontal);
}
else if (addr < 0xC000)
{
@ -110,7 +101,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
addr = (bank_1k << 10) | (addr & 0x3FF);
return Vrom[addr];
}
else return base.ReadPpu(addr);
return base.ReadPpu(addr);
}
public override byte ReadPrg(int addr)
@ -122,19 +114,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return Rom[((bank >> 1) << 15) + (addr & 0x7FFF)];
}
else
{
return Rom[((bank) << 14) + (addr & 0x3FFF)];
}
return Rom[((bank) << 14) + (addr & 0x3FFF)];
}
else
{
bank = mmc3.Get_PRGBank_8K(addr);
bank &= prg_mask_8k;
return Rom[(bank << 13) + (addr & 0x1FFF)];
}
bank = mmc3.Get_PRGBank_8K(addr);
bank &= prg_mask_8k;
return Rom[(bank << 13) + (addr & 0x1FFF)];
}
}
}

View File

@ -42,13 +42,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return base.ReadPrg(addr);
}
else
{
int b = addr >> 13;
b = exprg[b];
b &= prg_mask;
return Rom[addr & 0x1fff | b << 13];
}
int b = addr >> 13;
b = exprg[b];
b &= prg_mask;
return Rom[addr & 0x1fff | b << 13];
}
private void SinkMirror(bool flip)
@ -78,18 +76,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
bank &= chr_mask;
return Vrom[addr & 0x3ff | bank << 10];
}
else
{
return base.ReadPpu(addr);
}
return base.ReadPpu(addr);
}
// this is stupid as hell
public override void WritePrg(int addr, byte value)
{
//Console.WriteLine("{0:x4}:{1:x2}", addr, value);
if ((addr & 0x2131) == 0x2131 && (exmode != value))
{
exmode = value;
@ -131,8 +125,5 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
}
}
}
}
}

View File

@ -97,15 +97,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public override byte ReadPpu(int addr)
{
if (addr < 0x2000) return base.ReadPpu(addr);
else
if (addr < 0x2000)
{
int nt = ((addr - 0x2000) >> 10) & 0x3;
addr = 0x2000 + (addr & 0x3FF) + (nametables[nt] << 10);
return base.ReadPpu(addr);
}
int nt = ((addr - 0x2000) >> 10) & 0x3;
addr = 0x2000 + (addr & 0x3FF) + (nametables[nt] << 10);
return base.ReadPpu(addr);
}
public override void WritePpu(int addr, byte value)
{
if (addr < 0x2000) base.WritePpu(addr, value);
@ -115,7 +116,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
addr = 0x2000 + (addr & 0x3FF) + (nametables[nt] << 10);
base.WritePpu(addr, value);
}
}
public override void SyncState(Serializer ser)

View File

@ -36,10 +36,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
addr &= 0x1FFF;
return Vram[addr];
}
else return base.ReadPpu(addr);
}
else
return base.ReadPpu(addr);
}
return base.ReadPpu(addr);
}
public override void WritePpu(int addr, byte value)
@ -54,15 +55,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
addr &= 0x1FFF;
Vram[addr] = value;
}
//else
// if this address is mapped to chrrom and not chrram, the write just does nothing
//base.WritePPU(addr, value);
}
else
base.WritePpu(addr, value);
}
}
}

View File

@ -29,10 +29,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
return true;
}
//nesdev wiki says that the nes CIRAM doesnt get used at all.
//and that even though 8KB is really here, only 4KB gets used.
//still, purists could validate it.
// nesdev wiki says that the nes CIRAM doesnt get used at all.
// and that even though 8KB is really here, only 4KB gets used.
// still, purists could validate it.
public override byte ReadPpu(int addr)
{
if (addr < 0x2000)
@ -55,6 +54,5 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
Vram[addr & 0xFFF] = value;
}
}
}
}

View File

@ -30,7 +30,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
case "MAPPER116_HACKY":
break;
case "TXROM-HOMEBREW": // should this even exist?
break;
case "MAPPER004":
@ -68,7 +67,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
case "KONAMI-TLROM": //Super C
case "HVC-TLROM": //8 eyes (J)
case "ACCLAIM-TLROM":
AssertPrg(128, 256, 512); AssertChr(64, 128, 256); AssertVram(0); AssertWram(0);
AssertBattery(false);
break;
@ -107,14 +105,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
AssertPrg(128); AssertChr(128); AssertVram(0); AssertWram(0);
AssertBattery(false);
break;
default:
return false;
}
BaseSetup();
return true;
}
}

View File

@ -166,8 +166,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
if (addr < 0x2000)
return Vram[addr | chr << 13];
else
return base.ReadPpu(addr);
return base.ReadPpu(addr);
}
public override void WritePpu(int addr, byte value)

View File

@ -42,8 +42,7 @@
{
if (addr < 0x2000)
return Vram[addr | chr << 13];
else
return base.ReadPpu(addr);
return base.ReadPpu(addr);
}
public override void WritePpu(int addr, byte value)
{

View File

@ -77,7 +77,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
R++;
R &= 0x30;
}
break;
case 0x102:

View File

@ -40,10 +40,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return Vrom[addr + (chr << 13)];
}
else return base.ReadPpu(addr);
return base.ReadPpu(addr);
}
private void writereg(byte value)
private void WriteReg(byte value)
{
prg = value & 3 & prg_mask;
chr = (value >> 2) & 3 & chr_mask;
@ -54,13 +55,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public override void WritePrg(int addr, byte value)
{
//if ((addr & 0x7000) == 0x7000)
// writereg(value);
// WriteReg(value);
}
public override void WriteWram(int addr, byte value)
{
if ((addr & 0x1000) == 0x1000)
writereg(value);
WriteReg(value);
}
public override void SyncState(Serializer ser)

View File

@ -78,10 +78,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return Rom[addr];
}
else
{
return Rom[addr + 0x4000];
}
return Rom[addr + 0x4000];
}
public override byte ReadPrg(int addr)
@ -90,25 +88,23 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return Rom[addr + 0x2000];
}
else if (addr < 0x4000)
if (addr < 0x4000)
{
return Rom[addr - 0x2000];
}
else if (addr < 0x6000)
if (addr < 0x6000)
{
return Rom[(addr - 0x4000) + prg * 0x2000];
}
else
if (swap)
{
if (swap)
{
return Rom[(addr - 0x6000) + 8 * 0x2000];
}
else
{
return Rom[(addr - 0x6000) + 9 * 0x2000];
}
return Rom[(addr - 0x6000) + 8 * 0x2000];
}
return Rom[(addr - 0x6000) + 9 * 0x2000];
}
public override void ClockCpu()
@ -121,7 +117,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
irqenable = false;
IrqSignal = true;
}
}
}
}

View File

@ -92,7 +92,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
if (regs[2]==0)
{
return 0xFF;
}
}
return (0xFF >> ~((regs[2] & 0x0F)|0xF0));
}

View File

@ -2,20 +2,9 @@
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
// https://wiki.nesdev.com/w/index.php/INES_Mapper_046
internal sealed class Mapper046 : NesBoardBase
{
//Rumblestation 15-in-1 (Unl).nes
/*
Regs at $6000-7FFF means no PRG-RAM.
$6000-7FFF: [CCCC PPPP] High CHR, PRG bits
$8000-FFFF: [.CCC ...P] Low CHR, PRG bits
'C' selects 8k CHR @ $0000
'P' select 32k PRG @ $8000
*/
//configuration
private int prg_bank_mask_32k, chr_bank_mask_8k;

View File

@ -106,14 +106,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
private void SyncMirroring()
{
if (_mode == 0x12)
{
SetMirrorType(EMirrorType.Horizontal);
}
else
{
SetMirrorType(EMirrorType.Vertical);
}
SetMirrorType(_mode == 0x12 ? EMirrorType.Horizontal : EMirrorType.Vertical);
}
}
}

View File

@ -54,22 +54,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
prg_reg = (value >> 5) & 0x07;
prg_mode = value.Bit(4);
chr_reg_low_1 = (value & 0x07);
chr_reg_low_1 = value & 0x07;
if (value.Bit(3))
{
SetMirrorType(EMirrorType.Horizontal);
}
else
{
SetMirrorType(EMirrorType.Vertical);
}
SetMirrorType(value.Bit(3) ? EMirrorType.Horizontal : EMirrorType.Vertical);
}
chr_reg &= ~0x07;
chr_reg |= (chr_reg_low_0 | chr_reg_low_1);
//Console.WriteLine("chr page = {0}", chr_reg);
}
public override byte ReadPrg(int addr)
@ -78,10 +69,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return Rom[((prg_reg >> 1) * 0x8000) + addr];
}
else
{
return Rom[(prg_reg * 0x4000) + (addr & 0x3FFF)];
}
return Rom[(prg_reg * 0x4000) + (addr & 0x3FFF)];
}
public override byte ReadPpu(int addr)

View File

@ -38,14 +38,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public override void WritePrg(int addr, byte value)
{
prg_mode = addr.Bit(6);
if (addr.Bit(7))
{
SetMirrorType(EMirrorType.Horizontal);
}
else
{
SetMirrorType(EMirrorType.Vertical);
}
SetMirrorType(addr.Bit(7) ? EMirrorType.Horizontal : EMirrorType.Vertical);
prg_reg = addr & 0x07;
chr_reg = (addr >> 3) & 0x07;
@ -57,10 +50,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return Rom[((prg_reg >> 1) * 0x8000) + addr];
}
else
{
return Rom[(prg_reg * 0x4000) + (addr & 0x3FFF)];
}
return Rom[(prg_reg * 0x4000) + (addr & 0x3FFF)];
}
public override byte ReadPpu(int addr)

View File

@ -43,32 +43,28 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
if (open_bus)
{
return this.NES.DB;
return NES.DB;
}
else
{
return Rom[addr + prg0 * 0x2000];
}
return Rom[addr + prg0 * 0x2000];
}
else if (addr < 0x4000)
if (addr < 0x4000)
{
if (open_bus)
{
return this.NES.DB;
}
else
{
return Rom[(addr - 0x2000) + prg1 * 0x2000];
return NES.DB;
}
return Rom[(addr - 0x2000) + prg1 * 0x2000];
}
else if (addr < 0x6000)
if (addr < 0x6000)
{
return Rom[(addr - 0x4000) + prg2 * 0x2000];
}
else
{
return Rom[(addr - 0x6000) + prg3 * 0x2000];
}
return Rom[(addr - 0x6000) + prg3 * 0x2000];
}
public override void SyncState(Serializer ser)

View File

@ -270,13 +270,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
addr = CalcWRAMAddress(addr, prg_bank_mask_8k);
return Rom[addr];
}
else if (!wram_ram_enabled)
if (!wram_ram_enabled)
return 0xFF; //empty bus
else
{
addr = CalcWRAMAddress(addr, wram_bank_mask_8k);
return Wram[addr];
}
addr = CalcWRAMAddress(addr, wram_bank_mask_8k);
return Wram[addr];
}
public override void WriteWram(int addr, byte value)

View File

@ -56,20 +56,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
if (value.Bit(3) == false)
{
if (holydiver)
SetMirrorType(EMirrorType.Horizontal);
else
SetMirrorType(EMirrorType.OneScreenA);
SetMirrorType(holydiver ? EMirrorType.Horizontal : EMirrorType.OneScreenA);
}
else
{
if (holydiver)
SetMirrorType(EMirrorType.Vertical);
else
SetMirrorType(EMirrorType.OneScreenB);
SetMirrorType(holydiver ? EMirrorType.Vertical : EMirrorType.OneScreenB);
}
chr = (value >> 4);
chr = value >> 4;
}
public override byte ReadPrg(int addr)

View File

@ -396,7 +396,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
}
else
{
goto case 0x4002;
goto case 0x4002;
}
case 0x4001: //IRQ control
irq_count_down = value.Bit(7);
@ -457,24 +457,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
SetMirrorType(EMirrorType.Horizontal);
break;
case 2:
if (mapper_035)
{
SetMirrorType(EMirrorType.OneScreenB);
}
else
{
SetMirrorType(EMirrorType.OneScreenA);
}
SetMirrorType(mapper_035 ? EMirrorType.OneScreenB : EMirrorType.OneScreenA);
break;
case 3:
if (mapper_035)
{
SetMirrorType(EMirrorType.OneScreenA);
}
else
{
SetMirrorType(EMirrorType.OneScreenB);
}
SetMirrorType(mapper_035 ? EMirrorType.OneScreenA : EMirrorType.OneScreenB);
break;
}
break;
@ -639,10 +625,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
return Vrom[nt << 10 | offset];
}
else
{
return base.PeekPPU(addr);
}
return base.PeekPPU(addr);
}
public override byte ReadPpu(int addr)
@ -690,10 +674,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
return Vrom[nt << 10 | offset];
}
else
{
return base.ReadPpu(addr);
}
return base.ReadPpu(addr);
}
}
}

View File

@ -76,6 +76,5 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
ser.Sync(nameof(romenable), ref romenable);
ser.Sync(nameof(prg), ref prg);
}
}
}

View File

@ -62,6 +62,5 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
chr_bank_8k &= chr_bank_mask_8k;
prg_bank_32k &= prg_bank_mask_32k;
}
}
}

View File

@ -65,24 +65,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
if (addr <= 0x103 && addr >= 0x100)
reg[addr & 0x03] = value;
//reg[addr&0x03] = (byte)(value & 0x0f);
}
public override byte ReadExp(int addr)
{
/*if ((addr & 0x100) != 0)
return (byte)((NES.DB & (is173 ? 0x01 : 0xf0)) | reg[2]);
else if ((addr & 0x1000) == 0)
return NES.DB;
else
return 0xff;
*/
if (addr==0x100)
if (addr == 0x100)
return (byte)((reg[1] ^ reg[2]) | (0x40 | (is173 ? 0x01 : 0x00)));
else
return NES.DB;
return NES.DB;
}
public override byte ReadPrg(int addr)
@ -92,10 +81,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return Rom[addr & 0x3FFF];
}
else
{
return Rom[addr + ((prg & prg_mask) << 15)];
}
return Rom[addr + ((prg & prg_mask) << 15)];
}
public override byte ReadPpu(int addr)

View File

@ -49,10 +49,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return (byte)((_chrRegister & 0x3F) | (NES.DB & 0xC0));
}
else
{
return base.ReadExp(addr);
}
return base.ReadExp(addr);
}
public override byte ReadPpu(int addr)

View File

@ -26,8 +26,8 @@
{
if ((addr & 0x100) != 0)
return (byte)(NES.DB & 0xc0 | ~addr & 0x3f);
else
return NES.DB;
return NES.DB;
}
/* if this awful hack is uncommented, dancing blocks runs

View File

@ -96,11 +96,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
break;
case 0x4014:
// is this right??
if ((value & 1) != 0)
SetMirrorType(EMirrorType.Vertical);
else
SetMirrorType(EMirrorType.Horizontal);
break;
SetMirrorType((value & 1) != 0 ? EMirrorType.Vertical : EMirrorType.Horizontal);
break;
}
}

View File

@ -43,7 +43,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
reg = (byte)(value << 1 & 0x80);
}
base.WriteWram(addr, value);
}

View File

@ -41,7 +41,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
ser.Sync(nameof(prgRegC), ref prgRegC);
ser.Sync(nameof(prgRegE), ref prgRegE);
base.SyncState(ser);
}
@ -95,14 +94,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return Rom[(prgReg8 << 14) + (addr & 0x3FFF)];
}
else if (addr < 0x6000)
if (addr < 0x6000)
{
return Rom[(prgRegC << 13) + (addr & 0x1FFF)];
}
else
{
return Rom[(prgRegE << 13) + (addr & 0x1FFF)];
}
return Rom[(prgRegE << 13) + (addr & 0x1FFF)];
}
}
}

View File

@ -40,10 +40,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return Rom[(prg_reg * 0x4000) + addr];
}
else
{
return Rom[addr - 0x4000];
}
return Rom[addr - 0x4000];
}
public override byte ReadPpu(int addr)
@ -56,8 +54,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
addr = (bank << 11) | ofs;
return Vrom[addr];
}
else
return base.ReadPpu(addr);
return base.ReadPpu(addr);
}
public override void WritePrg(int addr, byte value)
@ -70,7 +68,5 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
case 0x4000: prg_reg = 8 | (value & 0x7); break;
}
}
}
}

View File

@ -36,14 +36,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public override void WritePrg(int addr, byte value)
{
if (addr.Bit(3))
{
SetMirrorType(EMirrorType.Horizontal);
}
else
{
SetMirrorType(EMirrorType.Vertical);
}
SetMirrorType(addr.Bit(3) ? EMirrorType.Horizontal : EMirrorType.Vertical);
int reg = addr & 0x07;
prg_reg_16k = reg & prg_bank_mask_16k;
chr_reg_8k = reg & chr_bank_mask_8k;
@ -55,10 +48,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return Rom[(prg_reg_16k * 0x4000) + addr];
}
else
{
return Rom[(prg_reg_16k * 0x4000) + addr - 0x4000];
}
return Rom[(prg_reg_16k * 0x4000) + addr - 0x4000];
}
public override byte ReadPpu(int addr)

View File

@ -79,14 +79,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
int bank = reg[i] & prg_mask_2k;
return Rom[(bank << 11) + (addr & 0x7FF)];
}
else if (addr < 0x4000)
if (addr < 0x4000)
{
return Rom[0x1A000 /* bank 0xd*/ + (addr & 0x1FFF)];
}
else
{
return Rom[0x1C000 /* bank 7*/ + (addr & 0x3FFF)];
}
return Rom[0x1C000 /* bank 7*/ + (addr & 0x3FFF)];
}
}
}

View File

@ -17,7 +17,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
switch (Cart.BoardType)
{
case "MAPPER225":
case "MAPPER255": // Duplicate of 225 accoring to: http://problemkaputt.de/everynes.htm
case "MAPPER255": // Duplicate of 225 according to: http://problemkaputt.de/everynes.htm
break;
default:
return false;
@ -44,14 +44,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
addr += 0x8000;
prg_mode = addr.Bit(12);
if (addr.Bit(13))
{
SetMirrorType(EMirrorType.Horizontal);
}
else
{
SetMirrorType(EMirrorType.Vertical);
}
SetMirrorType(addr.Bit(13) ? EMirrorType.Horizontal : EMirrorType.Vertical);
int high = (addr & 0x4000) >> 8;
prg_reg = (addr >> 6) & 0x3F | high;
@ -65,10 +58,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
int bank = (prg_reg >> 1) & prg_bank_mask_32k;
return Rom[(bank * 0x8000) + addr];
}
else
{
return Rom[((prg_reg & prg_bank_mask_16k) * 0x4000) + (addr & 0x3FFF)];
}
return Rom[((prg_reg & prg_bank_mask_16k) * 0x4000) + (addr & 0x3FFF)];
}
public override byte ReadPpu(int addr)

View File

@ -64,14 +64,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
prg_page |= ((value & 0x1F) + ((value & 0x80) >> 2));
prg_mode = value.Bit(5);
if (value.Bit(6))
{
SetMirrorType(EMirrorType.Vertical);
}
else
{
SetMirrorType(EMirrorType.Horizontal);
}
SetMirrorType(value.Bit(6) ? EMirrorType.Vertical : EMirrorType.Horizontal);
}
else if (addr == 1)
{

View File

@ -98,8 +98,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
_prgBanks16K[0] = (byte)(_prgBanks16K[0]&_prgBankMask16K);
_prgBanks16K[1] = (byte)(_prgBanks16K[1]&_prgBankMask16K);
if (M_horz) SetMirrorType(EMirrorType.Horizontal);
else SetMirrorType(EMirrorType.Vertical);
SetMirrorType(M_horz ? EMirrorType.Horizontal : EMirrorType.Vertical);
}
public override void WritePpu(int addr, byte value)

View File

@ -48,14 +48,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
prg_page = value & 0x1F;
prg_mode = value.Bit(5);
if (value.Bit(6))
{
SetMirrorType(EMirrorType.Vertical);
}
else
{
SetMirrorType(EMirrorType.Horizontal);
}
SetMirrorType(value.Bit(6) ? EMirrorType.Vertical : EMirrorType.Horizontal);
}
}
@ -67,23 +60,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return Rom[((prg_page & chip0_prg_bank_mask_16k) * 0x4000) + addr];
}
else
{
return Rom[(7 * 0x4000) + (addr & 0x3FFF)];
}
return Rom[(7 * 0x4000) + (addr & 0x3FFF)];
}
else
if (prg_mode == false)
{
if (prg_mode == false)
{
return Rom[((prg_page >> 1) * 0x8000) + addr + chip1_offset];
}
else
{
int page = prg_page + 8;
return Rom[(page * 0x4000) + (addr & 0x03FFF)];
}
return Rom[((prg_page >> 1) * 0x8000) + addr + chip1_offset];
}
int page = prg_page + 8;
return Rom[(page * 0x4000) + (addr & 0x03FFF)];
}
public override void NesSoftReset()

View File

@ -31,14 +31,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public override void WritePrg(int addr, byte value)
{
if (addr.Bit(7))
{
SetMirrorType(EMirrorType.Horizontal);
}
else
{
SetMirrorType(EMirrorType.Vertical);
}
SetMirrorType(addr.Bit(7) ? EMirrorType.Horizontal : EMirrorType.Vertical);
int prg_reg_P = (addr >> 1) & 0xF;
int prg_reg_L = (addr >> 5) & 1;

View File

@ -73,14 +73,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
int type = ((_reg >> 13) & 1) ^ 1;
if (type == 0)
{
SetMirrorType(EMirrorType.Horizontal);
}
else
{
SetMirrorType(EMirrorType.Vertical);
}
SetMirrorType(type == 0 ? EMirrorType.Horizontal : EMirrorType.Vertical);
}
}
}

View File

@ -34,7 +34,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
return true;
}
public override void SyncState(Serializer ser)
{
base.SyncState(ser);
@ -65,6 +64,5 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
prg_bank_32k &= prg_bank_mask_32k;
chr_bank_mask_8k &= chr_bank_mask_8k;
}
}
}

View File

@ -133,24 +133,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
return Vrom[((chr_bank & chr_bank_mask_8k) * 0x2000) + addr];
}
else
{
return base.ReadPpu(addr);
}
}
else
{
if (addr < 0x2000)
{
int chr_bank = (regs[4] << 2) | (regs[6]) | (regs[2] << 3);
return Vrom[((chr_bank & chr_bank_mask_8k) * 0x2000) + addr];
}
else
{
return base.ReadPpu(addr);
}
}
return base.ReadPpu(addr);
}
if (addr < 0x2000)
{
int chr_bank = (regs[4] << 2) | (regs[6]) | (regs[2] << 3);
return Vrom[((chr_bank & chr_bank_mask_8k) * 0x2000) + addr];
}
return base.ReadPpu(addr);
}
public override byte ReadPrg(int addr)

Some files were not shown because too many files have changed in this diff Show More