nes-fix lagrange point, including sound

This commit is contained in:
zeromus 2012-06-07 20:52:49 +00:00
parent 38d22b8549
commit cff7ba6d24
7 changed files with 38 additions and 3 deletions

View File

@ -146,6 +146,7 @@
<Compile Include="Consoles\Nintendo\NES\Boards\Mapper069.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\Mapper107.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\Mapper164.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\Mapper176.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\Mapper180.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\Mapper193.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\Mapper227.cs" />

View File

@ -69,7 +69,7 @@ Open bus and bus conflict emulation is not considered complete or thorough in an
079 NINA-06 Complete
080 Misc (J) Good
082 Misc (J) Complete
085 VRC7 Decent (no OPL sound)
085 VRC7 Decent (includes sound)
086 Misc (J) Decent (no sound)
087 Misc (J) Complete
088 Misc (J) Nothing

View File

@ -1026,6 +1026,9 @@ namespace BizHawk.Emulation.Consoles.Nintendo
}
else
MyGetSamples(samples);
//mix in the cart's extra sound circuit
nes.board.ApplyCustomAudio(samples);
}
//static BinaryWriter bw = new BinaryWriter(new FileStream("d:\\out.raw",FileMode.Create,FileAccess.Write,FileShare.Read));

View File

@ -39,6 +39,9 @@ namespace BizHawk.Emulation.Consoles.Nintendo
byte[] ROM { get; set; }
byte[] VROM { get; set; }
void SyncState(Serializer ser);
//mixes the board's custom audio into the supplied sample buffer
void ApplyCustomAudio(short[] samples);
};
@ -245,6 +248,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
}
protected void AssertBattery(bool has_bat) { Assert(Cart.wram_battery == has_bat); }
public virtual void ApplyCustomAudio(short[] samples) { }
}
//this will be used to track classes that implement boards
@ -372,6 +376,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo
cart.bad = true;
if (dict.ContainsKey("MMC3"))
cart.chips.Add(dict["MMC3"]);
if (dict.ContainsKey("PCB"))
cart.pcb = dict["PCB"];
return cart;
}

View File

@ -13,6 +13,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo
Func<int, int> remap;
//state
BizHawk.Emulation.Sound.YM2413 fm = new Sound.YM2413();
ByteBuffer prg_banks_8k = new ByteBuffer(4);
ByteBuffer chr_banks_1k = new ByteBuffer(8);
bool irq_mode;
@ -31,6 +33,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
public override void SyncState(Serializer ser)
{
base.SyncState(ser);
fm.SyncState(ser);
ser.Sync("prg_banks_8k", ref prg_banks_8k);
ser.Sync("chr_banks_1k", ref chr_banks_1k);
ser.Sync("irq_mode", ref irq_mode);
@ -65,7 +68,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
remap = (addr) => ((addr & 0xF000) | ((addr & 0x8) >> 3));
else if(Cart.pcb == "352402")
//lagrange point
remap = (addr) => ((addr & 0xF000) | ((addr & 0x10) >> 4));
remap = (addr) => ((addr & 0xF000) | ((addr & 0x30) >> 4));
else throw new Exception("Unknown PCB type for VRC7");
prg_bank_mask_8k = Cart.prg_size / 8 - 1;
@ -116,6 +119,18 @@ namespace BizHawk.Emulation.Consoles.Nintendo
else base.WritePPU(addr, value);
}
public override void ApplyCustomAudio(short[] samples)
{
short[] fmsamples = new short[samples.Length];
fm.GetSamples(fmsamples);
//naive mixing. need to study more
int len = samples.Length;
for (int i = 0; i < len; i++)
{
samples[i] = (short)((samples[i] >> 1) + (fmsamples[i] >> 1));
}
}
public override void WritePRG(int addr, byte value)
{
//Console.WriteLine(" mapping {0:X4} = {1:X2}", addr, value);
@ -129,10 +144,11 @@ namespace BizHawk.Emulation.Consoles.Nintendo
case 0x1001:
//sound address port
fm.RegisterLatch = value;
break;
case 0x1003:
//sound data port
//TODO - remap will break this
fm.Write(value);
break;
//a bit creepy to mask this for lagrange point which has no VROM, but the mask will be 0xFFFFFFFF so its OK

View File

@ -22,6 +22,12 @@ namespace BizHawk.Emulation.Sound
opll = OPLL_new(3579545, 44100);
}
public void SyncState(Serializer ser)
{
//TODO !! MUCH BETTER-NESS!
ser.Sync("RegisterLatch", ref RegisterLatch);
}
public void Reset()
{
OPLL_reset(opll);

View File

@ -73,6 +73,9 @@ sha1:8A5FD1061ADACDEABF422A2D2E555FF70749AE7C U Mississippi Satsujin Jiken (Alt)
;when they appear in bootgod's db then we can re-evaluate this category.
sha1:91CECCFCAC90E417E9AEE80E8F7B560A20EB33CC Ai Sensei No Oshiete - Watashi No Hoshi (J) NES board=IREM-G101;PRG=256;CHR=128;WRAM=8
;games which might be thought to be good according to goodnes, but arent really
sha1:C87E7E6A68DD9C7E24652CD2C7D390A14E8ADF04 B Lagrange Point NES board=KONAMI-VRC-7;PCB=352402
;;;;;;;;;;;;;;;;;;;-----------------------------------------------------------------------
;this is every game from goodNES which is clearly labeled as bad.
;well, it isnt very game yet. but we should make it every game, if we can! it would be a lot of games though