Merge pull request #718 from alyosha-tas/master
VS System initial commits
This commit is contained in:
commit
2c9710fc86
|
@ -780,6 +780,7 @@
|
||||||
<Compile Include="Consoles\Nintendo\NES\Boards\VRC3.cs" />
|
<Compile Include="Consoles\Nintendo\NES\Boards\VRC3.cs" />
|
||||||
<Compile Include="Consoles\Nintendo\NES\Boards\VRC6.cs" />
|
<Compile Include="Consoles\Nintendo\NES\Boards\VRC6.cs" />
|
||||||
<Compile Include="Consoles\Nintendo\NES\Boards\VRC7.cs" />
|
<Compile Include="Consoles\Nintendo\NES\Boards\VRC7.cs" />
|
||||||
|
<Compile Include="Consoles\Nintendo\NES\Boards\VS_M99.cs" />
|
||||||
<Compile Include="Consoles\Nintendo\NES\BisqAPU.cs" />
|
<Compile Include="Consoles\Nintendo\NES\BisqAPU.cs" />
|
||||||
<Compile Include="Consoles\Nintendo\NES\FDS\FDS.cs" />
|
<Compile Include="Consoles\Nintendo\NES\FDS\FDS.cs" />
|
||||||
<Compile Include="Consoles\Nintendo\NES\FDS\FDSAudio.cs" />
|
<Compile Include="Consoles\Nintendo\NES\FDS\FDSAudio.cs" />
|
||||||
|
@ -1190,4 +1191,4 @@
|
||||||
<Target Name="AfterBuild">
|
<Target Name="AfterBuild">
|
||||||
</Target>
|
</Target>
|
||||||
-->
|
-->
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -0,0 +1,152 @@
|
||||||
|
using System;
|
||||||
|
using BizHawk.Common;
|
||||||
|
|
||||||
|
namespace BizHawk.Emulation.Cores.Nintendo.NES
|
||||||
|
{
|
||||||
|
//VS System Mapper 99
|
||||||
|
|
||||||
|
[NES.INESBoardImplPriority]
|
||||||
|
public sealed class MAPPER99 : NES.NESBoardBase
|
||||||
|
{
|
||||||
|
//configuration
|
||||||
|
int prg_byte_mask, chr_mask;
|
||||||
|
|
||||||
|
//state
|
||||||
|
int chr;
|
||||||
|
|
||||||
|
[MapperProp]
|
||||||
|
public byte Dip_Switch_1;
|
||||||
|
[MapperProp]
|
||||||
|
public byte Dip_Switch_2;
|
||||||
|
[MapperProp]
|
||||||
|
public byte Dip_Switch_3;
|
||||||
|
[MapperProp]
|
||||||
|
public byte Dip_Switch_4;
|
||||||
|
[MapperProp]
|
||||||
|
public byte Dip_Switch_5;
|
||||||
|
[MapperProp]
|
||||||
|
public byte Dip_Switch_6;
|
||||||
|
[MapperProp]
|
||||||
|
public byte Dip_Switch_7;
|
||||||
|
[MapperProp]
|
||||||
|
public byte Dip_Switch_8;
|
||||||
|
|
||||||
|
//the VS actually does have 2 KB of nametable address space
|
||||||
|
//let's make the extra space here, instead of in the main NES to avoid confusion
|
||||||
|
byte[] CIRAM_VS = new byte[0x800];
|
||||||
|
|
||||||
|
public override bool Configure(NES.EDetectionOrigin origin)
|
||||||
|
{
|
||||||
|
//configure
|
||||||
|
switch (Cart.board_type)
|
||||||
|
{
|
||||||
|
case "MAPPER099":
|
||||||
|
NES._isVS = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
prg_byte_mask = Cart.prg_size * 1024 - 1;
|
||||||
|
chr_mask = (Cart.chr_size / 8) - 1;
|
||||||
|
|
||||||
|
AutoMapperProps.Apply(this);
|
||||||
|
|
||||||
|
|
||||||
|
//update the state of the dip switches
|
||||||
|
//this is only done at power on
|
||||||
|
NES.VS_dips[0] = (byte)(Dip_Switch_1 & 1);
|
||||||
|
NES.VS_dips[1] = (byte)(Dip_Switch_2 & 1);
|
||||||
|
NES.VS_dips[2] = (byte)(Dip_Switch_3 & 1);
|
||||||
|
NES.VS_dips[3] = (byte)(Dip_Switch_4 & 1);
|
||||||
|
NES.VS_dips[4] = (byte)(Dip_Switch_5 & 1);
|
||||||
|
NES.VS_dips[5] = (byte)(Dip_Switch_6 & 1);
|
||||||
|
NES.VS_dips[6] = (byte)(Dip_Switch_7 & 1);
|
||||||
|
NES.VS_dips[7] = (byte)(Dip_Switch_8 & 1);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// this now tracks coins
|
||||||
|
public override void WriteEXP(int addr, byte value)
|
||||||
|
{
|
||||||
|
//but we don't actually need to do anything yet
|
||||||
|
}
|
||||||
|
|
||||||
|
public override byte ReadEXP(int addr)
|
||||||
|
{
|
||||||
|
//what are we reading?
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override byte ReadPPU(int addr)
|
||||||
|
{
|
||||||
|
if (addr < 0x2000)
|
||||||
|
{
|
||||||
|
return VROM[(addr & 0x1FFF) + (NES.VS_chr_reg << 13)];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
addr = addr - 0x2000;
|
||||||
|
if (addr<0x800)
|
||||||
|
{
|
||||||
|
return NES.CIRAM[addr];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return CIRAM_VS[addr-0x800];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void WritePPU(int addr, byte value)
|
||||||
|
{
|
||||||
|
if (addr < 0x2000)
|
||||||
|
{
|
||||||
|
if (VRAM != null)
|
||||||
|
VRAM[addr] = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
addr = addr - 0x2000;
|
||||||
|
if (addr < 0x800)
|
||||||
|
{
|
||||||
|
NES.CIRAM[addr] = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CIRAM_VS[addr-0x800] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void SyncState(Serializer ser)
|
||||||
|
{
|
||||||
|
base.SyncState(ser);
|
||||||
|
ser.Sync("chr", ref chr);
|
||||||
|
ser.Sync("VS_CIRAM", ref CIRAM_VS, false);
|
||||||
|
ser.Sync("Dip_1", ref Dip_Switch_1);
|
||||||
|
ser.Sync("Dip_2", ref Dip_Switch_2);
|
||||||
|
ser.Sync("Dip_3", ref Dip_Switch_3);
|
||||||
|
ser.Sync("Dip_4", ref Dip_Switch_4);
|
||||||
|
ser.Sync("Dip_5", ref Dip_Switch_5);
|
||||||
|
ser.Sync("Dip_6", ref Dip_Switch_6);
|
||||||
|
ser.Sync("Dip_7", ref Dip_Switch_7);
|
||||||
|
ser.Sync("Dip_8", ref Dip_Switch_8);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override byte ReadPRG(int addr)
|
||||||
|
{
|
||||||
|
if (Cart.prg_size==40)
|
||||||
|
{
|
||||||
|
return ROM[(addr & 0x1FFF) + (NES.VS_prg_reg << 13)];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return ROM[addr];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -37,6 +37,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
||||||
|
|
||||||
//variable to change controller read/write behaviour when keyboard is attached
|
//variable to change controller read/write behaviour when keyboard is attached
|
||||||
public bool _iskeyboard = false;
|
public bool _iskeyboard = false;
|
||||||
|
//variable set when VS system games are running
|
||||||
|
public bool _isVS = false;
|
||||||
|
//since prg reg for VS System is set in the controller regs, it is convenient to have it here
|
||||||
|
//instead of in the board
|
||||||
|
public byte VS_chr_reg;
|
||||||
|
public byte VS_prg_reg;
|
||||||
|
//various VS controls
|
||||||
|
public byte[] VS_dips = new byte[8];
|
||||||
|
public byte VS_service = 0;
|
||||||
|
public byte VS_coin_inserted=0;
|
||||||
|
public byte VS_ROM_control;
|
||||||
|
|
||||||
// new input system
|
// new input system
|
||||||
NESControlSettings ControllerSettings; // this is stored internally so that a new change of settings won't replace
|
NESControlSettings ControllerSettings; // this is stored internally so that a new change of settings won't replace
|
||||||
|
@ -272,7 +283,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
||||||
ram[0x701] = 0xFF;
|
ram[0x701] = 0xFF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -516,6 +526,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
||||||
case 0x4014: /*OAM DMA*/ break;
|
case 0x4014: /*OAM DMA*/ break;
|
||||||
case 0x4015: return (byte)((byte)(apu.ReadReg(addr) & 0xDF) + (byte)(DB & 0x20));
|
case 0x4015: return (byte)((byte)(apu.ReadReg(addr) & 0xDF) + (byte)(DB & 0x20));
|
||||||
case 0x4016:
|
case 0x4016:
|
||||||
|
if (_isVS)
|
||||||
|
{
|
||||||
|
byte ret = 0;
|
||||||
|
// for whatever reason, in VS left and right controller have swapped regs
|
||||||
|
ret = read_joyport(0x4017);
|
||||||
|
ret &= 1;
|
||||||
|
ret = (byte)(ret | (VS_service << 2) | (VS_dips[0] << 3) | (VS_dips[1] << 4) | (VS_coin_inserted << 5) | (VS_ROM_control<<7));
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
// special hardware glitch case
|
// special hardware glitch case
|
||||||
ret_spec = read_joyport(addr);
|
ret_spec = read_joyport(addr);
|
||||||
|
@ -534,6 +555,18 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
||||||
// eventually this will be the keyboard function, but for now it is a place holder (no keys pressed)
|
// eventually this will be the keyboard function, but for now it is a place holder (no keys pressed)
|
||||||
return 0x1E;
|
return 0x1E;
|
||||||
}
|
}
|
||||||
|
else if (_isVS)
|
||||||
|
{
|
||||||
|
byte ret = 0;
|
||||||
|
// for whatever reason, in VS left and right controller have swapped regs
|
||||||
|
ret = read_joyport(0x4016);
|
||||||
|
ret &= 1;
|
||||||
|
|
||||||
|
ret = (byte)(ret | (VS_dips[2] << 2) | (VS_dips[3] << 3) | (VS_dips[4] << 4) | (VS_dips[5] << 5) | (VS_dips[6] << 6) | (VS_dips[7] << 7));
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return read_joyport(addr);
|
return read_joyport(addr);
|
||||||
|
@ -618,6 +651,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
||||||
{
|
{
|
||||||
// eventually keyboard emulation will go here
|
// eventually keyboard emulation will go here
|
||||||
}
|
}
|
||||||
|
else if (_isVS)
|
||||||
|
{
|
||||||
|
write_joyport(val);
|
||||||
|
VS_chr_reg = (byte)((val & 0x4)>>2);
|
||||||
|
|
||||||
|
//TODO: does other stuff for dual system
|
||||||
|
|
||||||
|
//this is actually different then assignment
|
||||||
|
VS_prg_reg = (byte)((val & 0x4)>>2);
|
||||||
|
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
write_joyport(val);
|
write_joyport(val);
|
||||||
|
@ -666,7 +710,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
||||||
/// Sets the provided palette as current.
|
/// Sets the provided palette as current.
|
||||||
/// Applies the current deemph settings if needed to expand a 64-entry palette to 512
|
/// Applies the current deemph settings if needed to expand a 64-entry palette to 512
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void SetPalette(byte[,] pal)
|
public void SetPalette(byte[,] pal)
|
||||||
{
|
{
|
||||||
int nColors = pal.GetLength(0);
|
int nColors = pal.GetLength(0);
|
||||||
int nElems = pal.GetLength(1);
|
int nElems = pal.GetLength(1);
|
||||||
|
|
|
@ -76,8 +76,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
||||||
ser.Sync("special_case_delay", ref special_case_delay);
|
ser.Sync("special_case_delay", ref special_case_delay);
|
||||||
ser.Sync("do_the_reread", ref do_the_reread);
|
ser.Sync("do_the_reread", ref do_the_reread);
|
||||||
|
|
||||||
|
//VS related
|
||||||
|
ser.Sync("VS", ref _isVS);
|
||||||
|
ser.Sync("VS_CHR", ref VS_chr_reg);
|
||||||
|
ser.Sync("VS_PRG", ref VS_prg_reg);
|
||||||
|
ser.Sync("VS_DIPS", ref VS_dips, false);
|
||||||
|
ser.Sync("VS_Service", ref VS_service);
|
||||||
|
ser.Sync("VS_Coin", ref VS_coin_inserted);
|
||||||
|
ser.Sync("VS_ROM_Control", ref VS_ROM_control);
|
||||||
|
|
||||||
ser.BeginSection("Board");
|
ser.BeginSection("Board");
|
||||||
Board.SyncState(ser);
|
Board.SyncState(ser);
|
||||||
if (Board is NESBoardBase && !((NESBoardBase)Board).SyncStateFlag)
|
if (Board is NESBoardBase && !((NESBoardBase)Board).SyncStateFlag)
|
||||||
throw new InvalidOperationException("the current NES mapper didnt call base.SyncState");
|
throw new InvalidOperationException("the current NES mapper didnt call base.SyncState");
|
||||||
|
|
|
@ -57,6 +57,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
||||||
}
|
}
|
||||||
PutSettings((NESSettings)Settings ?? new NESSettings());
|
PutSettings((NESSettings)Settings ?? new NESSettings());
|
||||||
|
|
||||||
|
// we need to put this here because the line directly above will overwrite palette intialization anywhere else
|
||||||
|
if (_isVS)
|
||||||
|
{
|
||||||
|
Console.WriteLine(palette_compiled[0]);
|
||||||
|
//Settings.Palette = (byte[,])Palettes.palette_2c04.Clone();
|
||||||
|
SetPalette(Palettes.palette_2c04_B);
|
||||||
|
Console.WriteLine(palette_compiled[0]);
|
||||||
|
Console.WriteLine(Palettes.QuickNESPalette[0, 0]);
|
||||||
|
Console.WriteLine(Palettes.palette_2c04[0, 0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ser.Register<IDisassemblable>(cpu);
|
ser.Register<IDisassemblable>(cpu);
|
||||||
|
|
||||||
|
|
|
@ -187,5 +187,74 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
||||||
{0, 0, 0},
|
{0, 0, 0},
|
||||||
{0, 0, 0},
|
{0, 0, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static byte[,] palette_2c04_B =
|
||||||
|
{
|
||||||
|
{4<<5, 3<<5, 0<<5},
|
||||||
|
{3<<5, 2<<5, 6<<5},
|
||||||
|
{0<<5, 4<<5, 4<<5},
|
||||||
|
{6<<5, 6<<5, 0<<5},
|
||||||
|
{0<<5, 0<<5, 0<<5},
|
||||||
|
{7<<5, 5<<5, 5<<5},
|
||||||
|
{0<<5, 1<<5, 4<<5},
|
||||||
|
{6<<5, 3<<5, 0<<5},
|
||||||
|
{5<<5, 5<<5, 5<<5},
|
||||||
|
{3<<5, 1<<5, 0<<5},
|
||||||
|
{0<<5, 7<<5, 0<<5},
|
||||||
|
{0<<5, 0<<5, 3<<5},
|
||||||
|
{7<<5, 6<<5, 4<<5},
|
||||||
|
{7<<5, 7<<5, 0<<5},
|
||||||
|
{0<<5, 4<<5, 0<<5},
|
||||||
|
{5<<5, 7<<5, 2<<5},
|
||||||
|
{7<<5, 3<<5, 7<<5},
|
||||||
|
{2<<5, 0<<5, 0<<5},
|
||||||
|
{0<<5, 2<<5, 7<<5},
|
||||||
|
{7<<5, 4<<5, 7<<5},
|
||||||
|
{0<<5, 0<<5, 0<<5},
|
||||||
|
{2<<5, 2<<5, 2<<5},
|
||||||
|
{5<<5, 1<<5, 0<<5},
|
||||||
|
{7<<5, 4<<5, 0<<5},
|
||||||
|
{6<<5, 5<<5, 3<<5},
|
||||||
|
{0<<5, 5<<5, 3<<5},
|
||||||
|
{4<<5, 4<<5, 7<<5},
|
||||||
|
{1<<5, 4<<5, 0<<5},
|
||||||
|
{4<<5, 0<<5, 3<<5},
|
||||||
|
{0<<5, 0<<5, 0<<5},
|
||||||
|
{4<<5, 7<<5, 3<<5},
|
||||||
|
{3<<5, 5<<5, 7<<5},
|
||||||
|
{5<<5, 0<<5, 3<<5},
|
||||||
|
{0<<5, 3<<5, 1<<5},
|
||||||
|
{4<<5, 2<<5, 0<<5},
|
||||||
|
{0<<5, 0<<5, 6<<5},
|
||||||
|
{4<<5, 0<<5, 7<<5},
|
||||||
|
{5<<5, 0<<5, 7<<5},
|
||||||
|
{3<<5, 3<<5, 3<<5},
|
||||||
|
{7<<5, 0<<5, 4<<5},
|
||||||
|
{0<<5, 2<<5, 2<<5},
|
||||||
|
{6<<5, 6<<5, 6<<5},
|
||||||
|
{0<<5, 3<<5, 6<<5},
|
||||||
|
{0<<5, 2<<5, 0<<5},
|
||||||
|
{1<<5, 1<<5, 1<<5},
|
||||||
|
{7<<5, 7<<5, 3<<5},
|
||||||
|
{4<<5, 4<<5, 4<<5},
|
||||||
|
{7<<5, 0<<5, 7<<5},
|
||||||
|
{7<<5, 5<<5, 7<<5},
|
||||||
|
{7<<5, 7<<5, 7<<5},
|
||||||
|
{3<<5, 2<<5, 0<<5},
|
||||||
|
{7<<5, 0<<5, 0<<5},
|
||||||
|
{7<<5, 6<<5, 0<<5},
|
||||||
|
{2<<5, 7<<5, 6<<5},
|
||||||
|
{7<<5, 7<<5, 7<<5},
|
||||||
|
{4<<5, 6<<5, 7<<5},
|
||||||
|
{0<<5, 0<<5, 0<<5},
|
||||||
|
{7<<5, 5<<5, 0<<5},
|
||||||
|
{6<<5, 3<<5, 7<<5},
|
||||||
|
{5<<5, 6<<5, 7<<5},
|
||||||
|
{3<<5, 6<<5, 0<<5},
|
||||||
|
{6<<5, 5<<5, 7<<5},
|
||||||
|
{0<<5, 7<<5, 7<<5},
|
||||||
|
{1<<5, 2<<5, 0<<5},
|
||||||
|
};
|
||||||
|
|
||||||
} //class palettes
|
} //class palettes
|
||||||
} //namespace
|
} //namespace
|
||||||
|
|
Loading…
Reference in New Issue