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

This reverts commit 2b5d0b6219.

A lot of these make things harder to read:

- Extra empty lines in large switch stacks mean they're more likely to go off one screen
- `if` and its condition on the same line is super hard to read, please never do that.  (Are the extra empty lines an attempt to mitigate the above)
- Removing terenaries obscures intent, and now there's more copy paste than before
- """Redundant""" else clauses on if...return kept things nice and lined up.

That was a huge churning diff with no value; let's stop it from spreading.
This commit is contained in:
nattthebear 2020-12-20 15:26:08 -05:00
parent 3d84812341
commit 55c08dc77f
165 changed files with 1482 additions and 767 deletions

View File

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

View File

@ -52,6 +52,7 @@ 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,6 +29,7 @@ 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
@ -40,10 +41,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;
@ -161,7 +162,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 separately
// for Jump2 boards, we only mask up to 256K, the outer bank is determined seperately
if (jump2)
prg_bank_mask_16k = 256 / 16 - 1;
@ -231,7 +232,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
irq_enabled = value.Bit(0);
if (jump2)
irq_counter = irq_latch;
// all write acknowledge
// all write acknolwedge
IrqSignal = false;
break;
case 0xB:
@ -345,6 +346,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
reader?.Clock();
}
public override byte ReadPrg(int addr)
{
int bank_16k = addr >> 14;
@ -369,7 +371,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
if (addr < 0x2000)
{
return vram ? Vram[addr] : Vrom[CalcPPUAddress(addr)];
if (vram)
return Vram[addr];
else
return Vrom[CalcPPUAddress(addr)];
}
return base.ReadPpu(addr);

View File

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

View File

@ -2,15 +2,16 @@
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;
@ -68,7 +69,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
if (addr < 0x2000)
return Vrom[(addr & 0x1FFF) + (chr * 0x2000)];
return base.ReadPpu(addr);
else
return base.ReadPpu(addr);
}
}
}

View File

@ -5,6 +5,8 @@ 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,11 +68,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return Vram[addr];
}
return Vrom[addr | (chr_bank_8k << 13)];
else
{
return Vrom[addr | (chr_bank_8k << 13)];
}
}
else
{
return base.ReadPpu(addr);
}
return base.ReadPpu(addr);
}
}
}

View File

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

View File

@ -20,15 +20,18 @@ 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;
@ -44,9 +47,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
if (addr < 0x1000)
return Vram[addr];
if(addr < 0x2000)
else if(addr<0x2000)
return Vram[addr - 0x1000 + (chr << 12)];
return base.ReadPpu(addr);
else return base.ReadPpu(addr);
}
public override void WritePpu(int addr, byte value)

View File

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

View File

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

View File

@ -134,6 +134,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
bank &= 0xFF;
return Vrom[(bank << 10) + (addr & 0x3FF)];
}
}
return base.ReadPpu(addr);
@ -187,9 +188,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
if (addr == 0x1000)
return (byte)((NES.DB & 0xFC) | 0);
if (addr >= 0x1100 && addr <= 0x1103)
else if (addr >= 0x1100 && addr <= 0x1103)
return _low[addr & 0x3];
return base.ReadExp(addr);
else
return base.ReadExp(addr);
}
}
@ -216,6 +218,9 @@ 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;
@ -308,14 +313,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);
@ -331,8 +336,7 @@ 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];
@ -342,7 +346,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
bank = prg_bank_mask_8k;
return Rom[(bank << 13) + (addr & 0x1FFF)];
}
}
public override void ClockCpu()
@ -371,9 +378,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
if (addr == 0x1000)
return (byte)((NES.DB & 0xFC) | 0);
if (addr >= 0x1100 && addr <= 0x1103)
else if (addr >= 0x1100 && addr <= 0x1103)
return _low[addr & 0x3];
return base.ReadExp(addr);
else
return base.ReadExp(addr);
}
}
@ -400,6 +409,7 @@ 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,11 +4,13 @@ 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];
@ -43,6 +45,16 @@ 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");
}
*/
}
}
}
@ -50,17 +62,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;
@ -82,7 +94,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);
@ -96,8 +108,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return (exp[2] & 15) << 3 | addr >> 10 & 7;
}
return base.Get_CHRBank_1K(addr);
else
{
return base.Get_CHRBank_1K(addr);
}
}
public override void SyncState(Serializer ser)

View File

@ -7,6 +7,7 @@ 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]
@ -66,6 +67,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
ser.EndSection();
}
public void Reset()
{
cycles = 0;
@ -77,6 +79,10 @@ 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)
{
@ -172,6 +178,7 @@ 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,6 +517,7 @@ 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;
@ -700,6 +701,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
SyncIRQ();
}
}
}
public override void ClockCpu()

View File

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

View File

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

View File

@ -1,8 +1,9 @@
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,6 +3,7 @@
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];
@ -52,14 +53,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
if (addr < 0x4000)
return NES.DB;
return Rom[addr & 0xfff];
else
return Rom[addr & 0xfff];
}
public override byte ReadPpu(int addr)
{
if (addr >= 0x2000)
return base.ReadPpu(addr);
return PatternTables[addr & 0xff];
else
return PatternTables[addr & 0xff];
}
public override void WritePrg(int addr, byte value)

View File

@ -52,6 +52,7 @@ 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)
@ -65,14 +66,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return Vrom[addr + (chr << 13)];
}
return base.ReadPpu(addr);
else 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,9 +3,11 @@ 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
{
@ -62,8 +64,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return Vrom[addr + (chr_bank_8k << 13)];
}
return base.ReadPpu(addr);
else return base.ReadPpu(addr);
}
public override void WritePrg(int addr, byte value)

View File

@ -2,15 +2,17 @@
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
// 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
//Mapper 77
//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":
@ -44,18 +46,18 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
if (addr < 0x0800)
return Vrom[addr + (chr * 0x0800)];
if (addr < 0x2000)
else if (addr < 0x2000)
return Vram[addr];
if (addr < 0x2800)
else if (addr < 0x2800)
return Vram[addr & 0x7ff];
return base.ReadPpu(addr);
else return base.ReadPpu(addr);
}
public override void WritePpu(int addr, byte value)
{
if (addr < 0x0800)
return;
if (addr < 0x2000)
else if (addr < 0x2000)
Vram[addr] = value;
else if (addr < 0x2800)
Vram[addr & 0x7ff] = value;
@ -66,7 +68,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
if (addr < 0x8000)
return Rom[addr + (prg * 0x8000)];
return base.ReadPrg(addr);
else
return base.ReadPrg(addr);
}
}
}

View File

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

View File

@ -2,10 +2,12 @@
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
@ -66,9 +68,10 @@ 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)
@ -120,8 +123,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
addr = (bank_1k << 10) | ofs;
return Vrom[addr];
}
return base.ReadPpu(addr);
else
return base.ReadPpu(addr);
}
public override byte ReadPrg(int addr)

View File

@ -2,10 +2,13 @@
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
@ -55,6 +58,17 @@ 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;
@ -91,8 +105,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
addr = (bank_1k << 10) | ofs;
return Vrom[addr];
}
return base.ReadPpu(addr);
else
return base.ReadPpu(addr);
}
public override void WritePrg(int addr, byte value)

View File

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

View File

@ -2,11 +2,13 @@
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
@ -41,14 +43,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
if (addr < 0x8000)
return Rom[addr + (prg * 0x8000)];
return base.ReadPrg(addr);
else
return base.ReadPrg(addr);
}
public override byte ReadPpu(int addr)
{
if (addr < 0x2000)
return Vrom[(addr & 0x1FFF) + (chr * 0x2000)];
return base.ReadPpu(addr);
else
return base.ReadPpu(addr);
}
public override void WriteWram(int addr, byte value)

View File

@ -2,18 +2,19 @@
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
// iNES Mapper 72
// Example Games:
// --------------------------
// Pinball Quest (J)
// Moero!! Pro Tennis
// Moero!! Juudou Warriors
//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
// 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
@ -65,6 +66,8 @@ 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;
@ -94,10 +97,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
if (addr < 0x2000)
{
addr = ApplyMemoryMap(13, chr_banks_8k, addr);
return ReadPPUChr(addr);
return base.ReadPPUChr(addr);
}
return base.ReadPpu(addr);
else return base.ReadPpu(addr);
}
}
}

View File

@ -3,13 +3,15 @@ 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
@ -61,7 +63,25 @@ 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))
@ -83,10 +103,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
if (addr < 0x2000)
{
addr = ApplyMemoryMap(13, chr_banks_8k, addr);
return ReadPPUChr(addr);
return base.ReadPPUChr(addr);
}
return base.ReadPpu(addr);
else return base.ReadPpu(addr);
}
}
}

View File

@ -2,9 +2,10 @@
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;
@ -14,6 +15,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
private int irqcountwidth;
private bool irqcountpaused;
public override bool Configure(EDetectionOrigin origin)
{
//analyze board type
@ -205,10 +207,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
else
irqcountwidth = 16;
break;
case 0xF003:
// sound chip µPD7756C
break;
}
}
public override void ClockCpu()
@ -216,7 +221,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;
@ -229,7 +234,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
{
@ -264,10 +269,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
addr = MapCHR(addr);
if (Vrom != null)
return Vrom[addr];
return Vram[addr];
else return Vram[addr];
}
return base.ReadPpu(addr);
else return base.ReadPpu(addr);
}
}
}

View File

@ -3,22 +3,24 @@
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
/*
Life Span: October 1986 - April 1987
PCB Class: Jaleco-JF-11
Jaleco-JF-14
iNES Mapper 140
* 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]
*/
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;
@ -45,14 +47,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
if (addr < 0x8000)
return Rom[addr + (prg * 0x8000)];
return base.ReadPrg(addr);
else
return base.ReadPrg(addr);
}
public override byte ReadPpu(int addr)
{
if (addr < 0x2000)
return Vrom[(addr & 0x1FFF) + (chr * 0x2000)];
return base.ReadPpu(addr);
else
return base.ReadPpu(addr);
}
public override void WriteWram(int addr, byte value)

View File

@ -72,17 +72,27 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return eRAM[(addr & 0x07)];
}
return base.ReadExp(addr);
else
{
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;
SetMirrorType(addr.Bit(13) ? EMirrorType.Horizontal : EMirrorType.Vertical);
if (addr.Bit(13))
{
SetMirrorType(EMirrorType.Horizontal);
}
else
{
SetMirrorType(EMirrorType.Vertical);
}
prg_mode = addr.Bit(5);
prg_reg = (addr >> 6) & 0x1F;
@ -123,8 +133,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
int bank = (prg_reg >> 1) & prg_bank_mask_32k;
return Rom[(bank * 0x8000) + addr + chip_offset];
}
return Rom[((prg_reg & prg_bank_mask_16k) * 0x4000) + (addr & 0x3FFF) + chip_offset];
else
{
return Rom[((prg_reg & prg_bank_mask_16k) * 0x4000) + (addr & 0x3FFF) + chip_offset];
}
}
}
}

View File

@ -3,9 +3,10 @@ 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;
@ -125,6 +126,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
}
return value;
}
public override byte ReadPpu(int addr)

View File

@ -7,6 +7,8 @@ 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;
@ -111,5 +113,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
return base.ReadWram(addr);
return 0;
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -77,12 +77,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return Rom[((bank >> 1) << 15) + (addr & 0x7FFF)];
}
return Rom[(bank << 14) + (addr & 0x3FFF)];
else
{
return Rom[(bank << 14) + (addr & 0x3FFF)];
}
}
else
{
//return (byte)(base.ReadPRG(addr) & 0x3F);
return base.ReadPrg(addr);
}
//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)ScrambleA000(value);
value = (byte)scramble_A000(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 ScrambleA000(byte val)
private static int scramble_A000(byte val)
{
return (val & ~0x7) | scramble_table[val & 0x7];
}

View File

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

View File

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

View File

@ -1,8 +1,9 @@
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
@ -46,6 +47,7 @@
}
}
public override byte ReadPpu(int addr)
{
if (addr < 0x2000)
@ -56,28 +58,26 @@
byte value = Vram[addr & 0x03FF];
return value;
}
if (bank == 0x09)
else if (bank == 0x09)
{
return Vram[(addr & 0x03FF) + 0x400];
}
if (bank == 0x0A)
else if (bank == 0x0A)
{
return Vram[(addr & 0x03FF) + 0x800];
}
if (bank == 0x0B)
else if (bank == 0x0B)
{
return Vram[(addr & 0x03FF) + 0xC00];
}
addr = MapCHR(addr);
return Vrom[addr + extra_vrom];
else
{
addr = MapCHR(addr);
return Vrom[addr + extra_vrom];
}
}
return base.ReadPpu(addr);
else return base.ReadPpu(addr);
}
}
}

View File

@ -1,8 +1,9 @@
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
@ -46,18 +47,18 @@
{
return Vram[addr & 0x03FF];
}
if (bank == 0x01)
else if (bank == 0x01)
{
return Vram[(addr & 0x03FF) + 0x400];
}
addr = MapCHR(addr);
return Vrom[addr + extra_vrom];
else
{
addr = MapCHR(addr);
return Vrom[addr + extra_vrom];
}
}
return base.ReadPpu(addr);
else return base.ReadPpu(addr);
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -2,9 +2,10 @@
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)
@ -96,10 +97,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
if (addr < 0x2000)
{
addr = MapCHR2(addr);
return Vrom?[addr + extra_vrom] ?? Vram[addr];
if (Vrom != null)
return Vrom[addr + extra_vrom];
else return Vram[addr];
}
return base.ReadPpu(addr);
else return base.ReadPpu(addr);
}
public override void NesSoftReset()

View File

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

View File

@ -5,13 +5,43 @@ 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)
@ -39,6 +69,7 @@ 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;
}
@ -56,14 +87,18 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
if ((exRegs[0] & 0x80) == 0)
{
int temp = mmc3.prg_regs_8k[i];
int temp = 0;
//for (int i=0;i<4;i++)
//{
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);
//}
}
}
@ -161,7 +196,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
}
else
{
SetMirrorType(value == 0 ? EMirrorType.Vertical : EMirrorType.Horizontal);
if (value==0)
{
SetMirrorType(EMirrorType.Vertical);
}
else
{
SetMirrorType(EMirrorType.Horizontal);
}
}
break;
case 0xA001:
@ -169,7 +211,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
break;
case 0xC000:
if (exRegs[2]>0)
SetMirrorType((value >> 7 | value) == 0 ? EMirrorType.Vertical : EMirrorType.Horizontal);
if ((value >> 7 | value) == 0)
{
SetMirrorType(EMirrorType.Vertical);
}
else
{
SetMirrorType(EMirrorType.Horizontal);
}
else
base.WritePrg(0x4000, value);
break;
@ -211,8 +260,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
addr = (bank_1k << 10) | (addr & 0x3FF);
return Vrom[addr];
}
return base.ReadPpu(addr);
else return base.ReadPpu(addr);
}
public override byte ReadPrg(int addr)

View File

@ -10,6 +10,7 @@ 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)
@ -49,16 +50,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public void sync_prg()
{
int temp = 0;
for (int i=0;i<4;i++)
{
int temp = mmc3.prg_regs_8k[i];
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);
}
}
@ -142,15 +144,28 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
}
else
{
SetMirrorType(value == 0 ? EMirrorType.Vertical : EMirrorType.Horizontal);
if (value == 0)
{
SetMirrorType(EMirrorType.Vertical);
}
else
{
SetMirrorType(EMirrorType.Horizontal);
}
}
break;
case 0xA001:
if (exRegs[2] > 0)
{
SetMirrorType(value == 0 ? EMirrorType.Vertical : EMirrorType.Horizontal);
}
else
if (value == 0)
{
SetMirrorType(EMirrorType.Vertical);
}
else
{
SetMirrorType(EMirrorType.Horizontal);
}
} else
{
base.WritePrg(0x2001, value);
}
@ -175,10 +190,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
addr = (bank_1k << 10) | (addr & 0x3FF);
return Vrom[addr];
}
return base.ReadPpu(addr);
else return base.ReadPpu(addr);
}
public override byte ReadPrg(int addr)
{
int bank = addr >> 13;

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))];
}
return base.ReadPpu(addr);
else
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)];
}
return base.ReadExp(addr);
else
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,14 +68,20 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return Vram[addr + 0x1000];
}
return Vram[addr - 0x1000];
else
{
return Vram[addr - 0x1000];
}
}
else
{
return Vram[addr];
}
return Vram[addr];
}
return base.ReadPpu(addr);
else
{
return base.ReadPpu(addr);
}
}
public override void WritePpu(int addr, byte value)

View File

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

View File

@ -55,7 +55,6 @@ 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)
@ -63,5 +62,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
block = value & 1;
}
}
}
}

View File

@ -5,6 +5,7 @@ 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;
@ -34,6 +35,7 @@ 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;
}
@ -60,7 +62,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
if (addr < 0xA000)
{
SetMirrorType(((value >> 7) | value) == 0 ? EMirrorType.Vertical : EMirrorType.Horizontal);
if (((value >> 7) | value)==0)
{
SetMirrorType(EMirrorType.Vertical);
}
else
{
SetMirrorType(EMirrorType.Horizontal);
}
}
else if (addr < 0xC000)
{
@ -101,8 +110,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
addr = (bank_1k << 10) | (addr & 0x3FF);
return Vrom[addr];
}
return base.ReadPpu(addr);
else return base.ReadPpu(addr);
}
public override byte ReadPrg(int addr)
@ -114,13 +122,19 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return Rom[((bank >> 1) << 15) + (addr & 0x7FFF)];
}
return Rom[((bank) << 14) + (addr & 0x3FFF)];
else
{
return Rom[((bank) << 14) + (addr & 0x3FFF)];
}
}
bank = mmc3.Get_PRGBank_8K(addr);
bank &= prg_mask_8k;
return Rom[(bank << 13) + (addr & 0x1FFF)];
else
{
bank = mmc3.Get_PRGBank_8K(addr);
bank &= prg_mask_8k;
return Rom[(bank << 13) + (addr & 0x1FFF)];
}
}
}
}

View File

@ -42,11 +42,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return base.ReadPrg(addr);
}
int b = addr >> 13;
b = exprg[b];
b &= prg_mask;
return Rom[addr & 0x1fff | b << 13];
else
{
int b = addr >> 13;
b = exprg[b];
b &= prg_mask;
return Rom[addr & 0x1fff | b << 13];
}
}
private void SinkMirror(bool flip)
@ -76,14 +78,18 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
bank &= chr_mask;
return Vrom[addr & 0x3ff | bank << 10];
}
return base.ReadPpu(addr);
else
{
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;
@ -125,5 +131,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
}
}
}
}
}

View File

@ -97,16 +97,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public override byte ReadPpu(int addr)
{
if (addr < 0x2000)
if (addr < 0x2000) return base.ReadPpu(addr);
else
{
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);
@ -116,6 +115,7 @@ 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,11 +36,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
addr &= 0x1FFF;
return Vram[addr];
}
return base.ReadPpu(addr);
else return base.ReadPpu(addr);
}
return base.ReadPpu(addr);
else
return base.ReadPpu(addr);
}
public override void WritePpu(int addr, byte value)
@ -55,9 +54,15 @@ 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,9 +29,10 @@ 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)
@ -54,5 +55,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
Vram[addr & 0xFFF] = value;
}
}
}
}

View File

@ -30,6 +30,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
case "MAPPER116_HACKY":
break;
case "TXROM-HOMEBREW": // should this even exist?
break;
case "MAPPER004":
@ -67,6 +68,7 @@ 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;
@ -105,11 +107,14 @@ 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,7 +166,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
if (addr < 0x2000)
return Vram[addr | chr << 13];
return base.ReadPpu(addr);
else
return base.ReadPpu(addr);
}
public override void WritePpu(int addr, byte value)

View File

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

View File

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

View File

@ -40,11 +40,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return Vrom[addr + (chr << 13)];
}
return base.ReadPpu(addr);
else 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;
@ -55,13 +54,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,8 +78,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return Rom[addr];
}
return Rom[addr + 0x4000];
else
{
return Rom[addr + 0x4000];
}
}
public override byte ReadPrg(int addr)
@ -88,23 +90,25 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return Rom[addr + 0x2000];
}
if (addr < 0x4000)
else if (addr < 0x4000)
{
return Rom[addr - 0x2000];
}
if (addr < 0x6000)
else if (addr < 0x6000)
{
return Rom[(addr - 0x4000) + prg * 0x2000];
}
if (swap)
else
{
return Rom[(addr - 0x6000) + 8 * 0x2000];
if (swap)
{
return Rom[(addr - 0x6000) + 8 * 0x2000];
}
else
{
return Rom[(addr - 0x6000) + 9 * 0x2000];
}
}
return Rom[(addr - 0x6000) + 9 * 0x2000];
}
public override void ClockCpu()
@ -117,7 +121,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,9 +2,20 @@
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,7 +106,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
private void SyncMirroring()
{
SetMirrorType(_mode == 0x12 ? EMirrorType.Horizontal : EMirrorType.Vertical);
if (_mode == 0x12)
{
SetMirrorType(EMirrorType.Horizontal);
}
else
{
SetMirrorType(EMirrorType.Vertical);
}
}
}
}

View File

@ -54,13 +54,22 @@ 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);
SetMirrorType(value.Bit(3) ? EMirrorType.Horizontal : EMirrorType.Vertical);
if (value.Bit(3))
{
SetMirrorType(EMirrorType.Horizontal);
}
else
{
SetMirrorType(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)
@ -69,8 +78,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return Rom[((prg_reg >> 1) * 0x8000) + addr];
}
return Rom[(prg_reg * 0x4000) + (addr & 0x3FFF)];
else
{
return Rom[(prg_reg * 0x4000) + (addr & 0x3FFF)];
}
}
public override byte ReadPpu(int addr)

View File

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

View File

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

View File

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

View File

@ -56,14 +56,20 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
if (value.Bit(3) == false)
{
SetMirrorType(holydiver ? EMirrorType.Horizontal : EMirrorType.OneScreenA);
if (holydiver)
SetMirrorType(EMirrorType.Horizontal);
else
SetMirrorType(EMirrorType.OneScreenA);
}
else
{
SetMirrorType(holydiver ? EMirrorType.Vertical : EMirrorType.OneScreenB);
if (holydiver)
SetMirrorType(EMirrorType.Vertical);
else
SetMirrorType(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,10 +457,24 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
SetMirrorType(EMirrorType.Horizontal);
break;
case 2:
SetMirrorType(mapper_035 ? EMirrorType.OneScreenB : EMirrorType.OneScreenA);
if (mapper_035)
{
SetMirrorType(EMirrorType.OneScreenB);
}
else
{
SetMirrorType(EMirrorType.OneScreenA);
}
break;
case 3:
SetMirrorType(mapper_035 ? EMirrorType.OneScreenA : EMirrorType.OneScreenB);
if (mapper_035)
{
SetMirrorType(EMirrorType.OneScreenA);
}
else
{
SetMirrorType(EMirrorType.OneScreenB);
}
break;
}
break;
@ -625,8 +639,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
return Vrom[nt << 10 | offset];
}
return base.PeekPPU(addr);
else
{
return base.PeekPPU(addr);
}
}
public override byte ReadPpu(int addr)
@ -674,8 +690,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
return Vrom[nt << 10 | offset];
}
return base.ReadPpu(addr);
else
{
return base.ReadPpu(addr);
}
}
}
}

View File

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

View File

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

View File

@ -65,13 +65,24 @@ 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)
/*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)
return (byte)((reg[1] ^ reg[2]) | (0x40 | (is173 ? 0x01 : 0x00)));
return NES.DB;
else
return NES.DB;
}
public override byte ReadPrg(int addr)
@ -81,8 +92,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return Rom[addr & 0x3FFF];
}
return Rom[addr + ((prg & prg_mask) << 15)];
else
{
return Rom[addr + ((prg & prg_mask) << 15)];
}
}
public override byte ReadPpu(int addr)

View File

@ -49,8 +49,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
return (byte)((_chrRegister & 0x3F) | (NES.DB & 0xC0));
}
return base.ReadExp(addr);
else
{
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);
return NES.DB;
else
return NES.DB;
}
/* if this awful hack is uncommented, dancing blocks runs

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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