[NES] some little speedups, just to prove that it can be done

This commit is contained in:
zeromus 2011-03-20 20:42:12 +00:00
parent db78d7b462
commit 82ad219461
5 changed files with 28 additions and 24 deletions

View File

@ -233,6 +233,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
int timer_counter; int timer_counter;
public int sample; public int sample;
int env_output, env_start_flag, env_divider, env_counter; int env_output, env_start_flag, env_divider, env_counter;
bool noise_bit = true;
public bool IsLenCntNonZero() { return len_cnt > 0; } public bool IsLenCntNonZero() { return len_cnt > 0; }
@ -304,7 +305,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
public void Run() public void Run()
{ {
if (timer_counter > 0) timer_counter--; if (timer_counter > 0) timer_counter--;
if (timer_counter == 0) if (timer_counter == 0 && period_cnt != 0)
{ {
//reload timer //reload timer
timer_counter = period_cnt; timer_counter = period_cnt;
@ -315,12 +316,12 @@ namespace BizHawk.Emulation.Consoles.Nintendo
shift_register >>= 1; shift_register >>= 1;
shift_register &= ~(1 << 14); shift_register &= ~(1 << 14);
shift_register |= (feedback << 14); shift_register |= (feedback << 14);
noise_bit = (shift_register & 1)!=0;
} }
sample = env_output; if (noise_bit || len_cnt==0) sample = 0;
if ((shift_register & 1) == 0) sample = 0; else
if (len_cnt == 0) sample = env_output;
sample = 0;
} }
} }
@ -546,7 +547,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
metaspu.buffer.clear(); metaspu.buffer.clear();
} }
void RunOne() public void RunOne()
{ {
pulse[0].Run(); pulse[0].Run();
pulse[1].Run(); pulse[1].Run();

View File

@ -250,7 +250,6 @@ namespace BizHawk.Emulation.Consoles.Nintendo
if (choices.Count == 0) return null; if (choices.Count == 0) return null;
//pick the first board for this hash arbitrarily. it probably doesn't make a difference //pick the first board for this hash arbitrarily. it probably doesn't make a difference
Console.WriteLine("Chose board from nescartdb:");
return choices[0]; return choices[0];
} }

View File

@ -65,6 +65,13 @@ namespace BizHawk.Emulation.Consoles.Nintendo
bool resetSignal; bool resetSignal;
public void FrameAdvance(bool render) public void FrameAdvance(bool render)
{ {
if (resetSignal)
{
cpu.PC = cpu.ReadWord(MOS6502.ResetVector);
apu.WriteReg(0x4015, 0);
cpu.FlagI = true;
}
Controller.UpdateControls(Frame++); Controller.UpdateControls(Frame++);
if (resetSignal) if (resetSignal)
Controller.UnpressButton("Reset"); Controller.UnpressButton("Reset");
@ -74,24 +81,17 @@ namespace BizHawk.Emulation.Consoles.Nintendo
protected void RunCpu(int ppu_cycles) protected void RunCpu(int ppu_cycles)
{ {
if (resetSignal)
{
cpu.PC = cpu.ReadWord(MOS6502.ResetVector);
apu.WriteReg(0x4015, 0);
cpu.FlagI = true;
}
int cycles = ppu_cycles; int cycles = ppu_cycles;
if (ppu.PAL) if (ppu.PAL)
cycles *= 15; cycles *= 15;
else else
cycles *= 16; cycles <<= 4;
cpu_accumulate += cycles; cpu_accumulate += cycles;
int todo = cpu_accumulate / 48; if (cpu_accumulate >= 48)
cpu_accumulate -= todo * 48;
if (todo > 0)
{ {
int todo = cpu_accumulate / 48;
cpu_accumulate -= todo * 48;
cpu.Execute(todo); cpu.Execute(todo);
apu.Run(todo); apu.Run(todo);
} }

View File

@ -412,7 +412,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
CartInfo choice = null; CartInfo choice = null;
if(USE_DATABASE) if(USE_DATABASE)
choice = IdentifyFromBootGodDB(hash_sha1); choice = IdentifyFromBootGodDB(hash_sha1);
if(choice == null) if (choice == null)
{ {
if (USE_DATABASE) if (USE_DATABASE)
{ {
@ -435,10 +435,14 @@ namespace BizHawk.Emulation.Consoles.Nintendo
else else
{ {
origin = EDetectionOrigin.GameDB; origin = EDetectionOrigin.GameDB;
Console.WriteLine("Chose board from gamedb: "); Console.WriteLine("Chose board from gamedb: " + board);
} }
} }
else origin = EDetectionOrigin.BootGodDB; else
{
Console.WriteLine("Chose board from nescartdb: " + choice.board_type);
origin = EDetectionOrigin.BootGodDB;
}
Console.WriteLine(choice.game); Console.WriteLine(choice.game);
Console.WriteLine(choice); Console.WriteLine(choice);

View File

@ -403,7 +403,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
//screen (or basically, the first nametable address that will be accessed when //screen (or basically, the first nametable address that will be accessed when
//the PPU is fetching background data on the next scanline). //the PPU is fetching background data on the next scanline).
//(not implemented yet) //(not implemented yet)
runppu(kFetchTime); runppu(kFetchTime*2);
if (sl == 0) if (sl == 0)
{ {
if (idleSynch && reg_2001.PPUON && !PAL) if (idleSynch && reg_2001.PPUON && !PAL)
@ -414,7 +414,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
} }
else else
ppur.status.end_cycle = 341; ppur.status.end_cycle = 341;
runppu(kFetchTime); //runppu(kFetchTime);
//After memory access 170, the PPU simply rests for 4 cycles (or the //After memory access 170, the PPU simply rests for 4 cycles (or the
//equivelant of half a memory access cycle) before repeating the whole //equivelant of half a memory access cycle) before repeating the whole